コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // timeout should be much lower in production, high due to latency / bandwidth via ADSL.
     $httpFetch = new HttpFetch(new Client(['timeout' => 5]), $output);
     $url = $httpFetch->fetchUrl($this->validateInputUrl($input, $output));
     $output->write(json_encode($url));
 }
コード例 #2
0
 /**
  * Test adding console output
  */
 public function testAttachConsoleOutput()
 {
     // setup our url and mock guzzle
     $expectedUrl = 'http://www.google.com/this-is-a-test';
     $mockHandler = new MockHandler([new Response(200)]);
     $handler = HandlerStack::create($mockHandler);
     $client = new Client(['handler' => $handler]);
     $output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $output->expects($this->once())->method('isVerbose')->willReturn(true);
     $output->expects($this->once())->method('writeln')->with(" > <info>Fetching {$expectedUrl}</info>");
     $sut = new HttpFetch($client);
     $sut->attachConsoleOutput($output);
     $url = $sut->fetchUrl($expectedUrl);
 }