ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SimpleDocumentMarkdownShapeTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 use ILIAS\Data;
27 
29 {
31 
32  protected function setUp(): void
33  {
34  $language = $this->createMock(ilLanguage::class);
35  $data_factory = new Data\Factory();
36  $refinery = new ILIAS\Refinery\Factory($data_factory, $language);
37  $this->simple_doc_markdown_shape = new SimpleDocumentMarkdown(new \ILIAS\Refinery\String\MarkdownFormattingToHTML());
38  }
39 
40  public static function constructDataProvider(): array
41  {
42  return [
43  [
44  Structure::BOLD,
45  Structure::ITALIC,
46  Structure::HEADING_1,
47  Structure::HEADING_2,
48  Structure::HEADING_3,
49  Structure::HEADING_4,
50  Structure::HEADING_5,
51  Structure::HEADING_6,
52  Structure::UNORDERED_LIST,
53  Structure::ORDERED_LIST,
54  Structure::PARAGRAPH,
55  Structure::LINK,
56  Structure::BLOCKQUOTE,
58  ]
59  ];
60  }
61 
62  public static function stringComplianceDataProvider(): array
63  {
64  return [
65  ["### Heading 3", true],
66  ["> Quote block", true],
67  ["![Image text](https://www.ilias.de)", false]
68  ];
69  }
70 
74  public function testGetSupportedStructure(
75  Structure $dp_bold,
76  Structure $dp_italic,
77  Structure $dp_heading_1,
78  Structure $dp_heading_2,
79  Structure $dp_heading_3,
80  Structure $dp_heading_4,
81  Structure $dp_heading_5,
82  Structure $dp_heading_6,
83  Structure $dp_unordered_list,
84  Structure $dp_ordered_list,
85  Structure $dp_paragraph,
86  Structure $dp_link,
87  Structure $dp_blockquote,
88  Structure $dp_code
89  ): void {
90  $supported_structure = $this->simple_doc_markdown_shape->getSupportedStructure();
91 
92  $expected = [
93  $dp_bold,
94  $dp_italic,
95  $dp_heading_1,
96  $dp_heading_2,
97  $dp_heading_3,
98  $dp_heading_4,
99  $dp_heading_5,
100  $dp_heading_6,
101  $dp_unordered_list,
102  $dp_ordered_list,
103  $dp_paragraph,
104  $dp_link,
105  $dp_blockquote,
106  $dp_code
107  ];
108 
109  $this->assertEquals($expected, $supported_structure);
110  }
111 
115  public function testIsRawStringCompliant(string $markdown_string, bool $compliance): void
116  {
117  $this->assertEquals($this->simple_doc_markdown_shape->isRawStringCompliant($markdown_string), $compliance);
118  }
119 }
testIsRawStringCompliant(string $markdown_string, bool $compliance)
stringComplianceDataProvider
Interface Observer Contains several chained tasks and infos about them.
testGetSupportedStructure(Structure $dp_bold, Structure $dp_italic, Structure $dp_heading_1, Structure $dp_heading_2, Structure $dp_heading_3, Structure $dp_heading_4, Structure $dp_heading_5, Structure $dp_heading_6, Structure $dp_unordered_list, Structure $dp_ordered_list, Structure $dp_paragraph, Structure $dp_link, Structure $dp_blockquote, Structure $dp_code)
constructDataProvider