From c9ca322825582dcb904a656e31e2e37067fabaef Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 22 Oct 2016 11:15:06 +0200 Subject: [PATCH] move test to the HttpKernel component --- .../Compiler/AddConsoleCommandPassTest.php | 20 ------------------- .../HttpKernel/Tests/Bundle/BundleTest.php | 15 ++++++++++++++ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php index 9750744859..97427034f5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php @@ -88,26 +88,6 @@ class AddConsoleCommandPassTest extends \PHPUnit_Framework_TestCase $container->compile(); } - - public function testHttpKernelRegisterCommandsIngoreCommandAsAService() - { - $container = new ContainerBuilder(); - $container->addCompilerPass(new AddConsoleCommandPass()); - $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand'); - $definition->addTag('console.command'); - $container->setDefinition('my-command', $definition); - $container->compile(); - - $application = $this->getMock('Symfony\Component\Console\Application'); - // Never called, because it's the - // Symfony\Bundle\FrameworkBundle\Console\Application that register - // commands as a service - $application->expects($this->never())->method('add'); - - $bundle = new ExtensionPresentBundle(); - $bundle->setContainer($container); - $bundle->registerCommands($application); - } } class MyCommand extends Command diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index 26dae365db..6320c0e8b2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\HttpKernel\Tests\Bundle; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; @@ -41,4 +42,18 @@ class BundleTest extends \PHPUnit_Framework_TestCase $bundle = new ExtensionNotValidBundle(); $bundle->getContainerExtension(); } + + public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAsServices() + { + $container = new ContainerBuilder(); + $container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); + + $application = $this->getMock('Symfony\Component\Console\Application'); + // add() is never called when the found command classes are already registered as services + $application->expects($this->never())->method('add'); + + $bundle = new ExtensionPresentBundle(); + $bundle->setContainer($container); + $bundle->registerCommands($application); + } }