mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Remote Context::root() usage
This commit is contained in:
parent
5d747aefc3
commit
cb03d99c97
@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional;
|
|||||||
|
|
||||||
use Nelmio\ApiDocBundle\OpenApiPhp\Util;
|
use Nelmio\ApiDocBundle\OpenApiPhp\Util;
|
||||||
use OpenApi\Analysis;
|
use OpenApi\Analysis;
|
||||||
|
use OpenApi\Context;
|
||||||
|
|
||||||
class SwaggerPHPApiComplianceTest extends WebTestCase
|
class SwaggerPHPApiComplianceTest extends WebTestCase
|
||||||
{
|
{
|
||||||
@ -25,12 +26,21 @@ class SwaggerPHPApiComplianceTest extends WebTestCase
|
|||||||
|
|
||||||
public function testAllContextsHaveSameRoot()
|
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();
|
$openApi = $this->getOpenApiDefinition();
|
||||||
$root = $openApi->_context;
|
$root = $openApi->_context;
|
||||||
|
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
foreach ((new Analysis([$openApi], Util::createContext()))->annotations as $annotation) {
|
foreach ((new Analysis([$openApi], Util::createContext()))->annotations as $annotation) {
|
||||||
$this->assertSame($annotation->_context->root(), $root);
|
$this->assertSame($getRootContext($annotation->_context), $root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -823,6 +823,7 @@ class UtilTest extends TestCase
|
|||||||
|
|
||||||
public function assertContextIsConnectedToRootContext(Context $context)
|
public function assertContextIsConnectedToRootContext(Context $context)
|
||||||
{
|
{
|
||||||
|
// zircote/swagger-php < 4.2 support
|
||||||
$getRootContext = \Closure::bind(function (Context $context) use (&$getRootContext) {
|
$getRootContext = \Closure::bind(function (Context $context) use (&$getRootContext) {
|
||||||
if (null !== $context->_parent) {
|
if (null !== $context->_parent) {
|
||||||
return $getRootContext($context->_parent);
|
return $getRootContext($context->_parent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user