|
31 | 31 | use Symfony\Component\Cache\DependencyInjection\CachePoolPass; |
32 | 32 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
33 | 33 | use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; |
| 34 | +use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; |
| 35 | +use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; |
34 | 36 | use Symfony\Component\DependencyInjection\ChildDefinition; |
35 | 37 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
36 | 38 | use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass; |
@@ -1614,6 +1616,55 @@ public function appRedisTagAwareConfigProvider(): array |
1614 | 1616 | ]; |
1615 | 1617 | } |
1616 | 1618 |
|
| 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 | + |
1617 | 1668 | public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug() |
1618 | 1669 | { |
1619 | 1670 | $container = $this->createContainer(['kernel.debug' => true]); |
|
0 commit comments