/** * Return the configured Scraper * @param ServiceLocatorInterface $serviceLocator * @return Scraper */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('NetglueTripAdvisor\\ScraperOptions'); $scraper = new Scraper($config); $cache = $serviceLocator->get('NetglueTripAdvisor\\Cache'); $scraper->setCache($cache); return $scraper; }
public function testRemoteLoadOfTheLondonRitz() { if ((int) $GLOBALS['SKIP_REMOTE'] === 1) { return $this->markTestSkipped(); } $options = new ScraperOptions(array('url' => 'http://www.tripadvisor.co.uk/Hotel_Review-g186338-d187591-Reviews-The_Ritz_London-London_England.html')); $scraper = new Scraper($options); $cache = \Zend\Cache\StorageFactory::factory(array('adapter' => 'filesystem', 'options' => array('cacheDir' => __DIR__ . '/../cache/', 'ttl' => 10))); $scraper->setCache($cache); $reviews = $scraper->getReviews(); $this->assertInternalType('array', $reviews); $this->assertGreaterThan(0, count($reviews)); $this->assertContainsOnlyInstancesOf('NetglueTripAdvisor\\Model\\Review', $reviews); return $scraper; }