mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Fix tests
This commit is contained in:
parent
5a6145fac8
commit
f63ab23fe5
@ -42,10 +42,10 @@ final class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('areas')
|
||||
->info('Filter the routes that are documented')
|
||||
->defaultValue(['default' => ['path_patterns' => [], 'host_patterns' => []]])
|
||||
->defaultValue(['default' => ['path_patterns' => [], 'host_patterns' => [], 'documentation' => []]])
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) {
|
||||
return 0 === count($v) || isset($v['path_patterns']) || isset($v['host_patterns']);
|
||||
return 0 === count($v) || isset($v['path_patterns']) || isset($v['host_patterns']) || isset($v['documentation']);
|
||||
})
|
||||
->then(function ($v) {
|
||||
return ['default' => $v];
|
||||
|
@ -20,18 +20,18 @@ class ConfigurationTest extends TestCase
|
||||
public function testDefaultArea()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(), [['areas' => ['path_patterns' => ['/foo']]]]);
|
||||
$config = $processor->processConfiguration(new Configuration(), [['areas' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []]]]);
|
||||
|
||||
$this->assertSame(['default' => ['path_patterns' => ['/foo'], 'host_patterns' => []]], $config['areas']);
|
||||
$this->assertSame(['default' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []]], $config['areas']);
|
||||
}
|
||||
|
||||
public function testAreas()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(), [['areas' => $areas = [
|
||||
'default' => ['path_patterns' => ['/foo'], 'host_patterns' => []],
|
||||
'internal' => ['path_patterns' => ['/internal'], 'host_patterns' => ['^swagger\.']],
|
||||
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => []],
|
||||
'default' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []],
|
||||
'internal' => ['path_patterns' => ['/internal'], 'host_patterns' => ['^swagger\.'], 'documentation' => []],
|
||||
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => [], 'documentation' => []],
|
||||
]]]);
|
||||
|
||||
$this->assertSame($areas, $config['areas']);
|
||||
@ -136,6 +136,6 @@ class ConfigurationTest extends TestCase
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(), [['routes' => ['path_patterns' => ['/foo']]]]);
|
||||
|
||||
$this->assertSame(['default' => ['path_patterns' => ['/foo'], 'host_patterns' => []]], $config['areas']);
|
||||
$this->assertSame(['default' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []]], $config['areas']);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ class NelmioApiDocExtensionTest extends TestCase
|
||||
$extension = new NelmioApiDocExtension();
|
||||
$extension->load([[
|
||||
'areas' => [
|
||||
'default' => ['path_patterns' => ['/foo'], 'host_patterns' => []],
|
||||
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => []],
|
||||
'default' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []],
|
||||
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => [], 'documentation' => []],
|
||||
],
|
||||
'models' => [
|
||||
'names' => [
|
||||
@ -92,33 +92,45 @@ class NelmioApiDocExtensionTest extends TestCase
|
||||
$extension = new NelmioApiDocExtension();
|
||||
$extension->load([
|
||||
[
|
||||
'documentation' => [
|
||||
'info' => [
|
||||
'title' => 'API documentation',
|
||||
'description' => 'This is the api documentation, use it wisely',
|
||||
],
|
||||
],
|
||||
'areas' => [
|
||||
'default' => [
|
||||
'documentation' => [
|
||||
'info' => [
|
||||
'title' => 'API documentation',
|
||||
'description' => 'This is the api documentation, use it wisely',
|
||||
],
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'documentation' => [
|
||||
'tags' => [
|
||||
[
|
||||
'name' => 'secured',
|
||||
'description' => 'Requires authentication',
|
||||
],
|
||||
[
|
||||
'name' => 'another',
|
||||
'description' => 'Another tag serving another purpose',
|
||||
'areas' => [
|
||||
'default' => [
|
||||
'documentation' => [
|
||||
'tags' => [
|
||||
[
|
||||
'name' => 'secured',
|
||||
'description' => 'Requires authentication',
|
||||
],
|
||||
[
|
||||
'name' => 'another',
|
||||
'description' => 'Another tag serving another purpose',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'documentation' => [
|
||||
'paths' => [
|
||||
'/api/v1/model' => [
|
||||
'get' => [
|
||||
'tags' => ['secured'],
|
||||
'areas' => [
|
||||
'default' => [
|
||||
'documentation' => [
|
||||
'paths' => [
|
||||
'/api/v1/model' => [
|
||||
'get' => [
|
||||
'tags' => ['secured'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -148,6 +160,6 @@ class NelmioApiDocExtensionTest extends TestCase
|
||||
],
|
||||
],
|
||||
],
|
||||
], $container->getDefinition('nelmio_api_doc.describers.config')->getArgument(0));
|
||||
], $container->getDefinition('nelmio_api_doc.describers.config.default')->getArgument(0));
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ class SwaggerUiTest extends WebTestCase
|
||||
$client = self::createClient();
|
||||
$crawler = $client->request('GET', '/app_dev.php/docs.json');
|
||||
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
|
||||
|
@ -117,7 +117,47 @@ class TestKernel extends Kernel
|
||||
|
||||
// Filter routes
|
||||
$c->loadFromExtension('nelmio_api_doc', [
|
||||
'documentation' => [
|
||||
'areas' => [
|
||||
'default' => ['path_patterns' => ['^/api(?!/admin)'], 'host_patterns' => ['^api\.'], 'documentation' => [
|
||||
'info' => [
|
||||
'title' => 'My Test App',
|
||||
],
|
||||
'definitions' => [
|
||||
'Test' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
],
|
||||
'parameters' => [
|
||||
'test' => [
|
||||
'name' => 'id',
|
||||
'in' => 'path',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
]],
|
||||
'test' => ['path_patterns' => ['^/test'], 'host_patterns' => ['^api-test\.'], 'documentation' => [
|
||||
'info' => [
|
||||
'title' => 'My Test App',
|
||||
],
|
||||
'definitions' => [
|
||||
'Test' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
],
|
||||
'parameters' => [
|
||||
'test' => [
|
||||
'name' => 'id',
|
||||
'in' => 'path',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
]],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 'documentation' => [
|
||||
'info' => [
|
||||
'title' => 'My Test App',
|
||||
],
|
||||
@ -134,12 +174,7 @@ class TestKernel extends Kernel
|
||||
],
|
||||
],
|
||||
],
|
||||
'areas' => [
|
||||
'default' => ['path_patterns' => ['^/api(?!/admin)'], 'host_patterns' => ['^api\.']],
|
||||
'test' => ['path_patterns' => ['^/test'], 'host_patterns' => ['^api-test\.']],
|
||||
],
|
||||
]);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
Loading…
x
Reference in New Issue
Block a user