]> git.mxchange.org Git - friendica.git/blob - tests/src/Content/Text/MarkdownTest.php
Tests, still ongoing ...
[friendica.git] / tests / src / Content / Text / MarkdownTest.php
1 <?php
2
3 namespace Friendica\Test\src\Content\Text;
4
5 use Friendica\Content\Text\Markdown;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\AppMockTrait;
8 use Friendica\Test\Util\VFSTrait;
9
10 class MarkdownTest 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 dataMarkdown()
23         {
24                 $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md');
25
26                 $data = [];
27
28                 foreach ($inputFiles as $file) {
29                         $data[str_replace('.md', '', $file)] = [
30                                 'input'    => file_get_contents($file),
31                                 'expected' => file_get_contents(str_replace('.md', '.html', $file))
32                         ];
33                 }
34
35                 return $data;
36         }
37
38         /**
39          * Test convert different input Markdown text into HTML
40          * @dataProvider dataMarkdown
41          *
42          * @param string $input    The Markdown text to test
43          * @param string $expected The expected HTML output
44          * @throws \Exception
45          */
46         public function testConvert($input, $expected)
47         {
48                 $output = Markdown::convert($input);
49
50                 $this->assertEquals($expected, $output);
51         }
52 }