/** * Execute command * * @param InputInterface $input Input * @param OutputInterface $output Output * * @return int * * @throws \Exception */ public function execute(InputInterface $input, OutputInterface $output) { $this->logger->info('Execute start command'); $isSuccessfull = $this->taskRunner->run($output); $exitCode = $isSuccessfull ? 0 : -1; $this->logger->info('Start command leave with exit code ' . $exitCode); return $exitCode; }
/** * @test TaskRunner:run */ public function testRun() { $mockOutput = Mockery::mock('Symfony\\Component\\Console\\Output\\OutputInterface'); // Validate with one successfull task $mockTask = Mockery::mock('QualityChecker\\Task\\TaskInterface'); $mockTask->shouldReceive('run')->with($mockOutput)->andReturn(true); $mockTask->shouldReceive('getConfiguration')->andReturn([]); $mockTask->shouldReceive('validateConfiguration'); $this->taskRunner->addTask($mockTask); $return = $this->taskRunner->run($mockOutput); $this->assertTrue($return); // Validate with two tasks and second failed $mockTask2 = Mockery::mock('QualityChecker\\Task\\TaskInterface'); $mockTask2->shouldReceive('run')->with($mockOutput)->andReturn(false); $mockTask2->shouldReceive('getConfiguration')->andReturn([]); $mockTask2->shouldReceive('validateConfiguration'); $this->taskRunner->addTask($mockTask2); $return = $this->taskRunner->run($mockOutput); $this->assertFalse($return); }