ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
MarkdownFormattingToHTMLTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use PHPUnit\Framework\TestCase;
26use ilLanguage;
28use PHPUnit\Framework\Attributes\DataProvider;
29
30class MarkdownFormattingToHTMLTest extends TestCase
31{
33
34 protected function setUp(): void
35 {
36 $language = $this->getMockBuilder(ilLanguage::class)
37 ->disableOriginalConstructor()
38 ->getMock();
39 $group = new Group(new Factory(), $language);
40
41 $this->markdown = $group->markdown()->toHTML();
42 }
43
44 public static function stringProvider(): array
45 {
46 return [
47 ["lorem", "<p>lorem</p>\n"],
48 ["lorem **ipsum**", "<p>lorem <strong>ipsum</strong></p>\n"],
49 ["_lorem_ **ipsum**", "<p><em>lorem</em> <strong>ipsum</strong></p>\n"],
50 ["# Headline", "<h1>Headline</h1>\n"],
51 ["## Headline", "<h2>Headline</h2>\n"],
52 ["### Headline", "<h3>Headline</h3>\n"],
53 ["1. Lorem\n2. Ipsum", "<ol>\n<li>Lorem</li>\n<li>Ipsum</li>\n</ol>\n"],
54 ["- Lorem\n- Ipsum", "<ul>\n<li>Lorem</li>\n<li>Ipsum</li>\n</ul>\n"],
55 ["[Link Titel](https://www.ilias.de)", "<p><a href=\"https://www.ilias.de\">Link Titel</a></p>\n"],
56 ];
57 }
58
59 #[DataProvider('stringProvider')]
60 public function testTransformationToHTML(
61 string $markdown_string,
62 string $expected_html,
63 ): void {
64 $this->assertEquals($expected_html, $this->markdown->transform($markdown_string));
65 }
66}
Builds data types.
Definition: Factory.php:36
testTransformationToHTML(string $markdown_string, string $expected_html,)
language handling
A transformation is a function from one datatype to another.