/** * Tests that we are scraping the expected data. * We test against the actual live url in order to flag up when * the provider changes their markup and breaks our scraper. * We basically want to ensure we are scraping the expected fields and that * they are not empty. */ public function testGatherPropertyData() { $scraper = new PropertyProvider(self::DATA_SOURCE); $data = $scraper->execute(); $this->assertEquals(3, sizeof($data)); $this->assertArrayContainsAttribute('name', $data); $this->assertArrayContainsAttribute('address', $data); $this->assertArrayContainsAttribute('description', $data); }
/** * {@inheritdoc} */ public function __construct(array $values = array()) { parent::__construct($values); $this->register(new TwigServiceProvider(), array('twig.path' => sprintf('%s/Views', __DIR__))); $this->get('/', function () { $scraper = new PropertyProvider(self::DATA_SOURCE); $propertyData = $scraper->execute(); return $this['twig']->render('page/property.html.twig', $propertyData); }); }