ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SimpleDocumentMarkdownShapeTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
24use ILIAS\Data;
25use ILIAS\Refinery\Factory as Refinery;
26use PHPUnit\Framework\MockObject\MockObject;
27
28class SimpleDocumentMarkdownShapeTest extends TestCase
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
71 #[\PHPUnit\Framework\Attributes\DataProvider('constructDataProvider')]
73 Structure $dp_bold,
74 Structure $dp_italic,
75 Structure $dp_heading_1,
76 Structure $dp_heading_2,
77 Structure $dp_heading_3,
78 Structure $dp_heading_4,
79 Structure $dp_heading_5,
80 Structure $dp_heading_6,
81 Structure $dp_unordered_list,
82 Structure $dp_ordered_list,
83 Structure $dp_paragraph,
84 Structure $dp_link,
85 Structure $dp_blockquote,
86 Structure $dp_code
87 ): void {
88 $supported_structure = $this->simple_doc_markdown_shape->getSupportedStructure();
89
90 $expected = [
91 $dp_bold,
92 $dp_italic,
93 $dp_heading_1,
94 $dp_heading_2,
95 $dp_heading_3,
96 $dp_heading_4,
97 $dp_heading_5,
98 $dp_heading_6,
99 $dp_unordered_list,
100 $dp_ordered_list,
101 $dp_paragraph,
102 $dp_link,
103 $dp_blockquote,
104 $dp_code
105 ];
106
107 $this->assertEquals($expected, $supported_structure);
108 }
109
110 #[\PHPUnit\Framework\Attributes\DataProvider('stringComplianceDataProvider')]
111 public function testIsRawStringCompliant(string $markdown_string, bool $compliance): void
112 {
113 $this->assertEquals($this->simple_doc_markdown_shape->isRawStringCompliant($markdown_string), $compliance);
114 }
115}
Builds data types.
Definition: Factory.php:36
testIsRawStringCompliant(string $markdown_string, bool $compliance)
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)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.