Esempio n. 1
0
 /**
  * Test continue if expected url
  *
  * @return void
  */
 public function testCrawler()
 {
     $html = '<a href="http:example.com"></a>';
     $client = $this->getMockClient();
     $domCrawler = $this->getMockDomCrawler()->makePartial();
     $response = Mockery::mock('GuzzleHttp\\Psr7\\Response')->makePartial();
     $client->shouldReceive('get')->andReturn($response);
     $response->shouldReceive('getHeaderLine')->andReturn('http://example.com', 'http://example.com/test', 'http://example.com/baz');
     $response->shouldReceive('getStatusCode')->andReturn(200);
     $domCrawler->shouldReceive('addHtmlContent')->andReturn($html);
     $crawling = new CrawlerUrl($client, $domCrawler);
     $crawling->setBaseUrl('http://example.com');
     $crawling->start();
     $this->assertEquals([], $crawling->getSiteUrl());
     $this->assertEquals([], $crawling->getUnvisitedUrl());
 }