public function testRegisterCommands()
 {
     $cmd = new FooCommand();
     $app = $this->getMock('Symfony\\Component\\Console\\Application');
     $app->expects($this->once())->method('add')->with($this->equalTo($cmd));
     $bundle = new ExtensionPresentBundle();
     $bundle->registerCommands($app);
     $bundle2 = new ExtensionAbsentBundle();
     $this->assertNull($bundle2->registerCommands($app));
 }
Example #2
0
 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);
 }
Example #3
0
 public function testRegisterCommands()
 {
     if (!class_exists('Symfony\\Component\\Console\\Application')) {
         $this->markTestSkipped('The "Console" component is not available');
     }
     if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
         $this->markTestSkipped('The "Finder" component is not available');
     }
     $cmd = new FooCommand();
     $app = $this->getMock('Symfony\\Component\\Console\\Application');
     $app->expects($this->once())->method('add')->with($this->equalTo($cmd));
     $bundle = new ExtensionPresentBundle();
     $bundle->registerCommands($app);
     $bundle2 = new ExtensionAbsentBundle();
     $this->assertNull($bundle2->registerCommands($app));
 }
Example #4
0
 public function testRegisterCommandsIngoreCommandAsAService()
 {
     $container = new ContainerBuilder();
     $container->addCompilerPass(new AddConsoleCommandPass());
     $definition = new Definition('Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionPresentBundle\\Command\\FooCommand');
     $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);
 }