3 namespace Friendica\Test\src\Content\Text;
5 use Friendica\Content\Text\HTML;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\AppMockTrait;
8 use Friendica\Test\Util\VFSTrait;
10 class HTMLTest extends MockedTest
15 protected function setUp()
19 $this->mockApp($this->root);
22 public function dataHTML()
24 $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/html/*.html');
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))
39 * Test convert different input Markdown text into HTML
41 * @dataProvider dataHTML
43 * @param string $input The Markdown text to test
44 * @param string $expected The expected HTML output
47 public function testToPlaintext($input, $expected)
49 $output = HTML::toPlaintext($input, 0);
51 $this->assertEquals($expected, $output);
54 public function dataHTMLText()
57 'bug-7665-audio-tag' => [
58 'expectedBBCode' => '[audio]http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3[/audio]',
59 'html' => '<audio src="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3" controls="controls"><a href="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3">http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3</a></audio>',
61 'bug-8075-html-tags' => [
62 'expectedBBCode' => "<rant here> I don't understand tests",
63 'html' => "<rant here> I don't understand tests",
69 * Test convert bbcodes to HTML
71 * @dataProvider dataHTMLText
73 * @param string $expectedBBCode Expected BBCode output
74 * @param string $html HTML text
75 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
77 public function testToBBCode($expectedBBCode, $html)
79 $actual = HTML::toBBCode($html);
81 $this->assertEquals($expectedBBCode, $actual);