Skip to content

Commit 157c95b

Browse files
committed
add DI tests
1 parent b262244 commit 157c95b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
3232
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
3333
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
34+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
35+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
3436
use Symfony\Component\DependencyInjection\ChildDefinition;
3537
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
3638
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
@@ -1614,6 +1616,55 @@ public function appRedisTagAwareConfigProvider(): array
16141616
];
16151617
}
16161618

1619+
public function testCacheTaggableTagAppliedToPools()
1620+
{
1621+
$container = $this->createContainerFromFile('cache');
1622+
1623+
$servicesToCheck = [
1624+
'cache.app.taggable' => 'cache.app',
1625+
'cache.redis_tag_aware.bar' => 'cache.redis_tag_aware.bar',
1626+
'.cache.foobar.taggable' => 'cache.foobar',
1627+
];
1628+
1629+
foreach ($servicesToCheck as $id => $expectedPool) {
1630+
$this->assertTrue($container->hasDefinition($id));
1631+
1632+
$def = $container->getDefinition($id);
1633+
1634+
$this->assertTrue($def->hasTag('cache.taggable'));
1635+
$this->assertSame($expectedPool, $def->getTag('cache.taggable')[0]['pool'] ?? null);
1636+
}
1637+
}
1638+
1639+
/**
1640+
* @dataProvider appRedisTagAwareConfigProvider
1641+
*/
1642+
public function testCacheTaggableTagAppliedToRedisAwareAppPool(string $configFile)
1643+
{
1644+
$container = $this->createContainerFromFile($configFile);
1645+
1646+
$def = $container->getDefinition('cache.app');
1647+
1648+
$this->assertTrue($def->hasTag('cache.taggable'));
1649+
$this->assertSame('cache.app', $def->getTag('cache.taggable')[0]['pool'] ?? null);
1650+
}
1651+
1652+
public function testCachePoolInvalidateTagsCommandRegistered()
1653+
{
1654+
$container = $this->createContainerFromFile('cache');
1655+
$this->assertTrue($container->hasDefinition('console.command.cache_pool_invalidate_tags'));
1656+
1657+
$locator = $container->getDefinition('console.command.cache_pool_invalidate_tags')->getArgument(0);
1658+
$this->assertInstanceOf(ServiceLocatorArgument::class, $locator);
1659+
1660+
$iterator = $locator->getTaggedIteratorArgument();
1661+
$this->assertInstanceOf(TaggedIteratorArgument::class, $iterator);
1662+
1663+
$this->assertSame('cache.taggable', $iterator->getTag());
1664+
$this->assertSame('pool', $iterator->getIndexAttribute());
1665+
$this->assertTrue($iterator->needsIndexes());
1666+
}
1667+
16171668
public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug()
16181669
{
16191670
$container = $this->createContainer(['kernel.debug' => true]);

0 commit comments

Comments
 (0)