public function testGetImages() { $document = new Document(file_get_contents(__DIR__ . '/fixtures/referencedUrls.html')); $urls = $document->getImages(new Uri('http://www.example.com/test/')); foreach ($urls as $url) { $currentUrls[] = (string) $url; } $expectedUrls = array('http://www.example.com/absolute_path.php'); sort($expectedUrls); sort($currentUrls); $this->assertEquals($currentUrls, $expectedUrls); }
protected function doValidation(Response $response) { $document = new Document($response->getBody()); $images = $document->getImages($response->getUri()); $foreignImages = array(); /* @var $currentUri Uri */ $currentUri = $response->getUri(); foreach ($images as $image) { /* @var $image Uri */ if ($currentUri->getHost($this->depth) !== $image->getHost($this->depth)) { $foreignImages[] = (string) $image; } } $this->assert(count($foreignImages) === 0, 'Images from a foreign domain where found (' . implode(', ', $foreignImages) . ')'); }