/**
  * Test for processing run of chain member command.
  */
 public function testOnConsoleCommandDisableAndMessageAtMemberOwnExecution()
 {
     $logger = $this->getMock('Symfony\\Bridge\\Monolog\\Logger', ['log'], ['name' => 'console.chain']);
     $manager = $this->getMock('ChainCommandBundle\\Console\\ChainManager', ['isMember', 'getMainCommands', 'hasChains', 'init'], [['foo:hello' => [0 => 'BarBundle\\Command\\HiCommand']], new EventDispatcher(), $logger]);
     $manager->expects(static::atLeastOnce())->method('isMember')->will(static::returnValue(true));
     $manager->expects(static::atLeastOnce())->method('getMainCommands')->will(static::returnValue([0 => 'foo:hello']));
     $manager->expects(static::atLeastOnce())->method('hasChains')->will(static::returnValue(false));
     $listener = new CommandListener($manager);
     $application = new Application();
     $command = new HiCommand();
     $command->setApplication($application);
     $event = new ConsoleCommandEvent($command, new ArrayInput([]), new ConsoleLoggedOutput($logger, 16));
     // test message on stdout throw logger
     $logger->expects(static::atLeastOnce())->method('log')->with(200, 'Error: "bar:hi" command is a member of "foo:hello" command chain and cannot be executed on its own.');
     $listener->onConsoleCommand($event);
     static::assertEquals(false, $event->commandShouldRun());
 }
 /**
  * Test for runChain method.
  */
 public function testRunChain()
 {
     $application = new Application();
     $mainCommand = new HelloCommand();
     $mainCommand->setApplication($application);
     $application->add($mainCommand);
     $memberCommand = new HiCommand();
     $memberCommand->setApplication($application);
     $application->add($memberCommand);
     $this->manager->init($application);
     $this->logger->expects(static::exactly(2))->method('log')->withConsecutive([200, 'Hello from Foo!'], [200, 'Hi from Bar!']);
     $this->manager->runChain($mainCommand, new ArrayInput(['command' => 'foo:hello', '--quiet' => true]));
 }