NelmioApiDocBundle/Tests/DependencyInjection/NelmioApiDocExtensionTest.php

86 lines
2.6 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2018-01-04 14:33:02 +01:00
namespace Nelmio\ApiDocBundle\Tests\DependencyInjection;
use Nelmio\ApiDocBundle\DependencyInjection\NelmioApiDocExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class NelmioApiDocExtensionTest extends TestCase
{
public function testMergesRootKeysFromMultipleConfigurations()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.bundles', []);
$extension = new NelmioApiDocExtension();
$extension->load([
[
'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',
],
],
],
],
[
'documentation' => [
'paths' => [
'/api/v1/model' => [
'get' => [
'tags' => ['secured'],
],
],
],
],
],
], $container);
$this->assertSame([
'info' => [
'title' => 'API documentation',
'description' => 'This is the api documentation, use it wisely',
],
'tags' => [
[
'name' => 'secured',
'description' => 'Requires authentication',
],
[
'name' => 'another',
'description' => 'Another tag serving another purpose',
],
],
'paths' => [
'/api/v1/model' => [
'get' => [
'tags' => ['secured'],
],
],
],
], $container->getDefinition('nelmio_api_doc.describers.config')->getArgument(0));
}
}