|
20 | 20 | use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
|
21 | 21 | use Symfony\Component\DependencyInjection\ChildDefinition;
|
22 | 22 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
| 23 | +use Symfony\Component\DependencyInjection\ContainerInterface; |
23 | 24 | use Symfony\Component\DependencyInjection\Definition;
|
24 | 25 | use Symfony\Component\DependencyInjection\Reference;
|
| 26 | +use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; |
25 | 27 |
|
26 | 28 | class CachePoolPassTest extends TestCase
|
27 | 29 | {
|
@@ -232,4 +234,33 @@ public function testChainAdapterPool()
|
232 | 234 | $this->assertInstanceOf(ChildDefinition::class, $doctrineCachePool);
|
233 | 235 | $this->assertSame('cache.app', $doctrineCachePool->getParent());
|
234 | 236 | }
|
| 237 | + |
| 238 | + public function testGlobalClearerAlias() |
| 239 | + { |
| 240 | + $container = new ContainerBuilder(); |
| 241 | + $container->setParameter('kernel.container_class', 'app'); |
| 242 | + $container->setParameter('kernel.project_dir', 'foo'); |
| 243 | + |
| 244 | + $container->register('cache.default_clearer', Psr6CacheClearer::class); |
| 245 | + |
| 246 | + $container->setDefinition('cache.system_clearer', new ChildDefinition('cache.default_clearer')); |
| 247 | + |
| 248 | + $container->setDefinition('cache.foo_bar_clearer', new ChildDefinition('cache.default_clearer')); |
| 249 | + $container->setAlias('cache.global_clearer', 'cache.foo_bar_clearer'); |
| 250 | + |
| 251 | + $container->register('cache.adapter.array', ArrayAdapter::class) |
| 252 | + ->setAbstract(true) |
| 253 | + ->addTag('cache.pool'); |
| 254 | + |
| 255 | + $cachePool = new ChildDefinition('cache.adapter.array'); |
| 256 | + $cachePool->addTag('cache.pool', ['clearer' => 'cache.system_clearer']); |
| 257 | + $container->setDefinition('app.cache_pool', $cachePool); |
| 258 | + |
| 259 | + $this->cachePoolPass->process($container); |
| 260 | + |
| 261 | + $definition = $container->getDefinition('cache.foo_bar_clearer'); |
| 262 | + |
| 263 | + $this->assertTrue($definition->hasTag('cache.pool.clearer')); |
| 264 | + $this->assertEquals(['app.cache_pool' => new Reference('app.cache_pool', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)], $definition->getArgument(0)); |
| 265 | + } |
235 | 266 | }
|
0 commit comments