public function testBuildWithDispatcher() { $crawler = $this->getMockForAbstractClass(CrawlerInterface::class); $parser = $this->getMockForAbstractClass(ParserInterface::class); $handler = $this->getMockForAbstractClass(HandlerInterface::class); $dispatcher = new EventDispatcher(); $builder = new ScraperBuilder($dispatcher); $scraper = $builder->build($crawler, $parser, $handler); $this->assertSame($dispatcher, $scraper->getEventDispatcher()); }
/** * @param ScraperEntity $scraper * * @return ScraperInterface */ public function createScraper(ScraperEntity $scraper) { $parser = $this->getParser($scraper); $crawler = $this->getCrawler($scraper->getCrawler()); $handler = $this->getHandler($scraper->getHandler()); $builder = new ScraperBuilder($this->eventDispatcher); return $builder->build($crawler, $parser, $handler); }