Esempio n. 1
0
 /**
  * Renders the output of the result of executing some urls given a client
  * instance
  *
  * If all urls are executed as expected, then the result of the operation
  * will be 0. Otherwise, the result will be 1.
  *
  * @param UrlChain          $urlChain Url chain
  * @param RendererInterface $renderer Renderer
  * @param OutputInterface   $output   Output
  *
  * @return int Result of the execution
  */
 public function execute(UrlChain $urlChain, RendererInterface $renderer, OutputInterface $output)
 {
     $result = 0;
     foreach ($urlChain->getUrls() as $url) {
         $result = $result | $this->executeUrl($this->client, $url, $renderer, $output);
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * 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);
 }