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