Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Brajkovic committed Mar 5, 2024
1 parent bbec92e commit 661e530
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@
<directory>tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
34 changes: 31 additions & 3 deletions tests/DependencyInjection/NelmioApiDocExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

use Nelmio\ApiDocBundle\DependencyInjection\NelmioApiDocExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class NelmioApiDocExtensionTest extends TestCase
{
use ExpectDeprecationTrait;

public function testNameAliasesArePassedToModelRegistry()
{
$container = new ContainerBuilder();
Expand Down Expand Up @@ -151,12 +154,32 @@ public function testMergesRootKeysFromMultipleConfigurations()
], $container->getDefinition('nelmio_api_doc.describers.config')->getArgument(0));
}

/**
* @group legacy
*/
public function testApiDocGeneratorWithCachePool()
{
$this->expectDeprecation('Since nelmio/api-doc-bundle 4.23: Using global cache config for all areas is deprecated. Define it on area level instead.');

$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',
],
],
'areas' => [
'default' => [
],
'area1' => [],
],
],
], $container);
$extension->load([
[
'documentation' => [
Expand All @@ -170,20 +193,25 @@ public function testApiDocGeneratorWithCachePool()
'item_id' => 'nelmio.docs',
],
'areas' => [
'default' => [],
'default' => [
'cache' => [
'pool' => 'test.cache.default',
'item_id' => 'nelmio.docs.default'
]
],
'area1' => [],
],
],
], $container);

$reference = $container->getDefinition('nelmio_api_doc.generator.default')->getArgument(2);
$this->assertSame('test.cache', (string) $reference);
$this->assertSame('test.cache.default', (string) $reference);

$reference = $container->getDefinition('nelmio_api_doc.generator.area1')->getArgument(2);
$this->assertSame('test.cache', (string) $reference);

$cacheItemId = $container->getDefinition('nelmio_api_doc.generator.default')->getArgument(3);
$this->assertSame('nelmio.docs', $cacheItemId);
$this->assertSame('nelmio.docs.default', $cacheItemId);

$cacheItemId = $container->getDefinition('nelmio_api_doc.generator.area1')->getArgument(3);
$this->assertSame('nelmio.docs', $cacheItemId);
Expand Down

0 comments on commit 661e530

Please sign in to comment.