Exemplo n.º 1
0
 /**
  * @param ScraperEntity $scraper
  */
 public function scrapeNext(ScraperEntity $scraper)
 {
     foreach ($this->crawler->getNextUrls() as $url) {
         if ($this->async) {
             $this->scrapeAfter($scraper, $url, new \DateTime());
         } else {
             $this->scrape($scraper, $url);
         }
     }
 }
Exemplo n.º 2
0
 public function testScrapeNextAsync()
 {
     $entity = new ScraperEntity();
     $url = 'http://www.treehouse.nl';
     $this->crawler->expects($this->once())->method('getNextUrls')->will($this->returnValue([$url]));
     /** @var \PHPUnit_Framework_MockObject_MockObject|Scraper $scraper */
     $scraper = $this->getMockBuilder(Scraper::class)->setConstructorArgs([$this->crawler, $this->parser, $this->handler])->setMethods(['scrapeAfter'])->getMock();
     $scraper->expects($this->once())->method('scrapeAfter')->with($entity, $url, $this->greaterThanOrEqual(new \DateTime()));
     $scraper->setAsync(true);
     $scraper->scrapeNext($entity);
 }