public function testOnConsoleChainTerminateLogMessage() { $application = new Application(); $command = new HelloCommand(); $command->setApplication($application); $this->logger->expects(static::once())->method('log')->with(200, 'Execution of foo:hello chain completed.'); $listener = new ChainLoggingListener($this->logger); $event = new ConsoleChainEvent($command, new ArrayInput([]), new ConsoleOutput(), ['bar:hi' => 'foo:hello']); $listener->onConsoleChainTerminate($event); }
/** * Test for processing run of chain master command. */ public function testOnConsoleCommandMainCommandExecution() { $logger = $this->getMock('Symfony\\Bridge\\Monolog\\Logger', ['log'], ['name' => 'console.chain']); $manager = $this->getMock('ChainCommandBundle\\Console\\ChainManager', ['isMember', 'runChain', 'hasChains', 'init'], [['foo:hello' => [0 => 'BarBundle\\Command\\HiCommand']], new EventDispatcher(), $logger]); $application = new Application(); $command = new HelloCommand(); $command->setApplication($application); $input = new ArrayInput([]); $manager->expects(static::atLeastOnce())->method('isMember')->will(static::returnValue(false)); $manager->expects(static::atLeastOnce())->method('runChain')->with($command, $input); $manager->expects(static::atLeastOnce())->method('hasChains')->will(static::returnValue(true)); $listener = new CommandListener($manager); $event = new ConsoleCommandEvent($command, $input, new ConsoleOutput()); $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])); }