4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DomCrawler\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DomCrawler\Image;
17 class ImageTest extends TestCase
20 * @expectedException \LogicException
22 public function testConstructorWithANonImgTag()
24 $dom = new \DOMDocument();
25 $dom->loadHTML('<html><div><div></html>');
27 new Image($dom->getElementsByTagName('div')->item(0), 'http://www.example.com/');
31 * @dataProvider getGetUriTests
33 public function testGetUri($url, $currentUri, $expected)
35 $dom = new \DOMDocument();
36 $dom->loadHTML(sprintf('<html><img alt="foo" src="%s" /></html>', $url));
37 $image = new Image($dom->getElementsByTagName('img')->item(0), $currentUri);
39 $this->assertEquals($expected, $image->getUri());
42 public function getGetUriTests()
45 array('/foo.png', 'http://localhost/bar/foo/', 'http://localhost/foo.png'),
46 array('foo.png', 'http://localhost/bar/foo/', 'http://localhost/bar/foo/foo.png'),