X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fdom-crawler%2FTests%2FImageTest.php;fp=vendor%2Fsymfony%2Fdom-crawler%2FTests%2FImageTest.php;h=309578a90233e7e399fa5b2717ef29d729037ca0;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/symfony/dom-crawler/Tests/ImageTest.php b/vendor/symfony/dom-crawler/Tests/ImageTest.php new file mode 100644 index 000000000..309578a90 --- /dev/null +++ b/vendor/symfony/dom-crawler/Tests/ImageTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\DomCrawler\Image; + +class ImageTest extends TestCase +{ + /** + * @expectedException \LogicException + */ + public function testConstructorWithANonImgTag() + { + $dom = new \DOMDocument(); + $dom->loadHTML('
'); + + new Image($dom->getElementsByTagName('div')->item(0), 'http://www.example.com/'); + } + + /** + * @dataProvider getGetUriTests + */ + public function testGetUri($url, $currentUri, $expected) + { + $dom = new \DOMDocument(); + $dom->loadHTML(sprintf('foo', $url)); + $image = new Image($dom->getElementsByTagName('img')->item(0), $currentUri); + + $this->assertEquals($expected, $image->getUri()); + } + + public function getGetUriTests() + { + return array( + array('/foo.png', 'http://localhost/bar/foo/', 'http://localhost/foo.png'), + array('foo.png', 'http://localhost/bar/foo/', 'http://localhost/bar/foo/foo.png'), + ); + } +}