/** * Executes all business logic inside this command * * This method returns 0 if all executions passed. 1 otherwise. * * @param OutputInterface $output Output * @param array $config Config * @param string $format Format * * @return integer Execution return */ protected function executeVisithor(OutputInterface $output, array $config, $format) { $renderer = $this->rendererFactory->create($format); $this->executor->build(); $urlChain = $this->urlGenerator->generate($config); $result = $this->executor->execute($urlChain, $renderer, $output); $this->executor->destroy(); return $result; }
/** * Test final result given first partial results * * @dataProvider dataExecute */ public function testExecute($firstStatusCode, $expectedResult) { /** * @var ClientInterface|ObjectProphecy $client */ $client = $this->prophesize('Visithor\\Client\\Interfaces\\ClientInterface'); $client->getResponseHTTPCode(Argument::any())->willReturn(200); $client->buildClient(Argument::any())->willReturn(Argument::any()); $client->destroyClient(Argument::any())->willReturn(Argument::any()); $urlChain = new UrlChain(); $urlChain->addUrl(new Url('', $firstStatusCode, []))->addUrl(new Url('', [200], []))->addUrl(new Url('', [200], [])); $executor = new Executor($client->reveal()); $result = $executor->execute($urlChain, $this->prophesize('Visithor\\Renderer\\Interfaces\\RendererInterface')->reveal(), $this->prophesize('Symfony\\Component\\Console\\Output\\OutputInterface')->reveal()); $this->assertEquals($expectedResult, $result); }
/** * Executes all business logic inside this command * * This method returns 0 if all executions passed. 1 otherwise. * * @param OutputInterface $output Output * @param array $config Config * @param string $format Format * * @return integer Execution return */ protected function executeVisithor(OutputInterface $output, array $config, $format) { $client = new GuzzleClient(); $rendererFactory = new RendererFactory(); $renderer = $rendererFactory->create($format); $executor = new Executor($client); $executor->build(); $urlGenerator = new UrlGenerator(new UrlFactory(), new UrlChainFactory()); $urlChain = $urlGenerator->generate($config); $result = $executor->execute($urlChain, $renderer, $output); $executor->build(); return $result; }