65ae05249808f43fee02487b335ab42bb13f54bc
[friendica.git/.git] / tests / src / Content / Text / HTMLTest.php
1 <?php
2
3 namespace Friendica\Test\src\Content\Text;
4
5 use Friendica\Content\Text\HTML;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\AppMockTrait;
8 use Friendica\Test\Util\VFSTrait;
9
10 class HTMLTest extends MockedTest
11 {
12         use VFSTrait;
13         use AppMockTrait;
14
15         protected function setUp()
16         {
17                 parent::setUp();
18                 $this->setUpVfsDir();
19                 $this->mockApp($this->root);
20         }
21
22         public function dataHTML()
23         {
24                 $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/html/*.html');
25
26                 $data = [];
27
28                 foreach ($inputFiles as $file) {
29                         $data[str_replace('.html', '', $file)] = [
30                                 'input'    => file_get_contents($file),
31                                 'expected' => file_get_contents(str_replace('.html', '.txt', $file))
32                         ];
33                 }
34
35                 return $data;
36         }
37
38         /**
39          * Test convert different input Markdown text into HTML
40          *
41          * @dataProvider dataHTML
42          *
43          * @param string $input    The Markdown text to test
44          * @param string $expected The expected HTML output
45          * @throws \Exception
46          */
47         public function testToPlaintext($input, $expected)
48         {
49                 $output = HTML::toPlaintext($input, 0);
50
51                 $this->assertEquals($expected, $output);
52         }
53 }