|
6 | 6 |
|
7 | 7 | class ImageTest extends TestCase |
8 | 8 | { |
9 | | - public function testImageDataProvider() { |
| 9 | + public function testImageDataWithAltProvider() { |
| 10 | + $this->expectNotToPerformAssertions(); |
10 | 11 | return array( |
11 | 12 | 'Without alt tag' => array( |
12 | 13 | 'html' => '<img src="http://example.com/example.jpg">', |
@@ -35,14 +36,55 @@ public function testImageDataProvider() { |
35 | 36 | ); |
36 | 37 | } |
37 | 38 |
|
| 39 | + public function testImageDataWithoutAltProvider() { |
| 40 | + $this->expectNotToPerformAssertions(); |
| 41 | + return array( |
| 42 | + 'Without alt tag' => array( |
| 43 | + 'html' => '<img src="http://example.com/example.jpg">', |
| 44 | + 'expected' => '', |
| 45 | + ), |
| 46 | + 'Without alt tag, wrapped in text' => array( |
| 47 | + 'html' => 'xx<img src="http://example.com/example.jpg">xx', |
| 48 | + 'expected' => 'xxxx', |
| 49 | + ), |
| 50 | + 'With alt tag' => array( |
| 51 | + 'html' => '<img src="http://example.com/example.jpg" alt="An example image">', |
| 52 | + 'expected' => '', |
| 53 | + ), |
| 54 | + 'With alt, and title tags' => array( |
| 55 | + 'html' => '<img src="http://example.com/example.jpg" alt="An example image" title="Should be ignored">', |
| 56 | + 'expected' => '', |
| 57 | + ), |
| 58 | + 'With alt tag, wrapped in text' => array( |
| 59 | + 'html' => 'xx<img src="http://example.com/example.jpg" alt="An example image">xx', |
| 60 | + 'expected' => 'xxxx', |
| 61 | + ), |
| 62 | + 'With italics' => array( |
| 63 | + 'html' => '<img src="shrek.jpg" alt="the ogrelord" /> Blah <i>blah</i> blah', |
| 64 | + 'expected' => ' Blah _blah_ blah' |
| 65 | + ) |
| 66 | + ); |
| 67 | + } |
| 68 | + |
38 | 69 | /** |
39 | | - * @dataProvider testImageDataProvider |
| 70 | + * @dataProvider testImageDataWithAltProvider |
40 | 71 | */ |
41 | | - public function testImages($html, $expected) |
| 72 | + public function testImagesAlt($html, $expected) |
42 | 73 | { |
43 | 74 | $html2text = new Html2Text($html); |
44 | 75 | $output = $html2text->getText(); |
45 | 76 |
|
46 | 77 | $this->assertEquals($expected, $output); |
47 | 78 | } |
| 79 | + |
| 80 | + /** |
| 81 | + * @dataProvider testImageDataWithoutAltProvider |
| 82 | + */ |
| 83 | + public function testImagesNoAlt($html, $expected) |
| 84 | + { |
| 85 | + $html2text = new Html2Text($html,array('alt_image' => 'hide')); |
| 86 | + $output = $html2text->getText(); |
| 87 | + |
| 88 | + $this->assertEquals($expected, $output); |
| 89 | + } |
48 | 90 | } |
0 commit comments