diff --git a/Tests/Functional/SwaggerPHPApiComplianceTest.php b/Tests/Functional/SwaggerPHPApiComplianceTest.php index d10348b..c09a6d2 100644 --- a/Tests/Functional/SwaggerPHPApiComplianceTest.php +++ b/Tests/Functional/SwaggerPHPApiComplianceTest.php @@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; use Nelmio\ApiDocBundle\OpenApiPhp\Util; use OpenApi\Analysis; +use OpenApi\Context; class SwaggerPHPApiComplianceTest extends WebTestCase { @@ -25,12 +26,21 @@ class SwaggerPHPApiComplianceTest extends WebTestCase public function testAllContextsHaveSameRoot() { + // zircote/swagger-php < 4.2 support + $getRootContext = \Closure::bind(function (Context $context) use (&$getRootContext) { + if (null !== $context->_parent) { + return $getRootContext($context->_parent); + } + + return $context; + }, null, Context::class); + $openApi = $this->getOpenApiDefinition(); $root = $openApi->_context; $counter = 0; foreach ((new Analysis([$openApi], Util::createContext()))->annotations as $annotation) { - $this->assertSame($annotation->_context->root(), $root); + $this->assertSame($getRootContext($annotation->_context), $root); } } } diff --git a/Tests/SwaggerPhp/UtilTest.php b/Tests/SwaggerPhp/UtilTest.php index c83b938..0eab434 100644 --- a/Tests/SwaggerPhp/UtilTest.php +++ b/Tests/SwaggerPhp/UtilTest.php @@ -823,6 +823,7 @@ class UtilTest extends TestCase public function assertContextIsConnectedToRootContext(Context $context) { + // zircote/swagger-php < 4.2 support $getRootContext = \Closure::bind(function (Context $context) use (&$getRootContext) { if (null !== $context->_parent) { return $getRootContext($context->_parent);