Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / vendor / symfony / dom-crawler / Tests / ImageTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DomCrawler\Tests;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DomCrawler\Image;
16
17 class ImageTest extends TestCase
18 {
19     /**
20      * @expectedException \LogicException
21      */
22     public function testConstructorWithANonImgTag()
23     {
24         $dom = new \DOMDocument();
25         $dom->loadHTML('<html><div><div></html>');
26
27         new Image($dom->getElementsByTagName('div')->item(0), 'http://www.example.com/');
28     }
29
30     /**
31      * @dataProvider getGetUriTests
32      */
33     public function testGetUri($url, $currentUri, $expected)
34     {
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);
38
39         $this->assertEquals($expected, $image->getUri());
40     }
41
42     public function getGetUriTests()
43     {
44         return array(
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'),
47         );
48     }
49 }