From 14c62dad5f93dd76f8f67cd239634c3c84e94250 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Fri, 27 Oct 2017 16:39:37 -0400 Subject: [PATCH] fix CachePoolPrunerPass to use correct command service id --- .../DependencyInjection/Compiler/CachePoolPrunerPass.php | 3 ++- .../Compiler/CachePoolPrunerPassTest.php | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php index cd79f58ce84cd..d02e2c372c3d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; +use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -26,7 +27,7 @@ class CachePoolPrunerPass implements CompilerPassInterface private $cacheCommandServiceId; private $cachePoolTag; - public function __construct($cacheCommandServiceId = 'cache.command.pool_pruner', $cachePoolTag = 'cache.pool') + public function __construct($cacheCommandServiceId = CachePoolPruneCommand::class, $cachePoolTag = 'cache.pool') { $this->cacheCommandServiceId = $cacheCommandServiceId; $this->cachePoolTag = $cachePoolTag; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php index 51dba222a3a44..0006070f51ddb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; @@ -24,7 +25,7 @@ class CachePoolPrunerPassTest extends TestCase public function testCompilerPassReplacesCommandArgument() { $container = new ContainerBuilder(); - $container->register('cache.command.pool_pruner')->addArgument(array()); + $container->register(CachePoolPruneCommand::class)->addArgument(array()); $container->register('pool.foo', FilesystemAdapter::class)->addTag('cache.pool'); $container->register('pool.bar', PhpFilesAdapter::class)->addTag('cache.pool'); @@ -35,7 +36,7 @@ public function testCompilerPassReplacesCommandArgument() 'pool.foo' => new Reference('pool.foo'), 'pool.bar' => new Reference('pool.bar'), ); - $argument = $container->getDefinition('cache.command.pool_pruner')->getArgument(0); + $argument = $container->getDefinition(CachePoolPruneCommand::class)->getArgument(0); $this->assertInstanceOf(IteratorArgument::class, $argument); $this->assertEquals($expected, $argument->getValues()); @@ -51,7 +52,7 @@ public function testCompilePassIsIgnoredIfCommandDoesNotExist() $container ->expects($this->atLeastOnce()) ->method('hasDefinition') - ->with('cache.command.pool_pruner') + ->with(CachePoolPruneCommand::class) ->will($this->returnValue(false)); $container @@ -73,7 +74,7 @@ public function testCompilePassIsIgnoredIfCommandDoesNotExist() public function testCompilerPassThrowsOnInvalidDefinitionClass() { $container = new ContainerBuilder(); - $container->register('cache.command.pool_pruner')->addArgument(array()); + $container->register(CachePoolPruneCommand::class)->addArgument(array()); $container->register('pool.not-found', NotFound::class)->addTag('cache.pool'); $pass = new CachePoolPrunerPass();