ILIAS  release_8 Revision v8.24
ilWebDAVMountInstructionsDocumentProcessorBaseTest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
21
23{
25 {
26 return new class () extends ilWebDAVMountInstructionsDocumentProcessorBase {
31 public function processMountInstructions(string $a_raw_mount_instructions): array
32 {
33 return [];
34 }
35 };
36 }
37
43 {
44 // Arrange
45 $instructions = 'hello world';
46 $doc_processor = $this->createDocumentProcessorBaseObject();
47
48 // Act
49 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
50
51 // Assert
52 $this->assertEquals($instructions, $parsed_instructions[0]);
53 }
54
60 {
61 // Arrange
62 $instructions = 'This is a start [tag] with no end tag';
63 $doc_processor = $this->createDocumentProcessorBaseObject();
64
65 // Act
66 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
67
68 // Assert
69 $this->assertEquals($instructions, $parsed_instructions[0]);
70 }
71
77 {
78 // Arrange
79 $instructions = 'There is no start tag but an end [/tag] in the string';
80 $doc_processor = $this->createDocumentProcessorBaseObject();
81
82 // Act
83 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
84
85 // Assert
86 $this->assertEquals($instructions, $parsed_instructions[0]);
87 }
88
94 {
95 // Arrange
96 $instrunction_text = 'This are the mount Instructions';
97 $tag_title = 'tag';
98 $start_tag = "[$tag_title]";
99 $end_tag = "[/$tag_title]";
100 $instructions = $start_tag . $instrunction_text . $end_tag;
101 $doc_processor = $this->createDocumentProcessorBaseObject();
102
103 // Act
104 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
105
106 // Assert
107 $this->assertEquals($instrunction_text, $parsed_instructions[$tag_title]);
108 }
109
115 {
116 // Arrange
117 $instruction_text = 'This are the mount Instructions';
118 $tag_title = 'tag with spaces';
119 $start_tag = "[$tag_title]";
120 $end_tag = "[/$tag_title]";
121 $instructions = $start_tag . $instruction_text . $end_tag;
122 $doc_processor = $this->createDocumentProcessorBaseObject();
123
124 // Act
125 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
126
127 // Assert
128 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
129 }
130
136 {
137 // Arrange
138 $instruction_text = 'This are the mount Instructions';
139 $tag_title = 'tag_w!th$pecial"chars?';
140 $start_tag = "[$tag_title]";
141 $end_tag = "[/$tag_title]";
142 $instructions = $start_tag . $instruction_text . $end_tag;
143 $doc_processor = $this->createDocumentProcessorBaseObject();
144
145 // Act
146 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
147
148 // Assert
149 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
150 }
151
157 {
158 // Arrange
159 $instruction_text = 'This are the mount Instructions';
160 $tag_title = 'tag';
161 $start_tag = "[$tag_title]";
162 $end_tag = "[/$tag_title]";
163 $instructions = 'This will be cut off' . $start_tag . $instruction_text . $end_tag . 'and this of will be cut off as well';
164 $doc_processor = $this->createDocumentProcessorBaseObject();
165
166 // Act
167 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
168
169 // Assert
170 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
171 }
172
178 {
179 // Arrange
180 $instruction_text = 'This are the mount Instructions';
181 $tag_title = 'tag';
182 $start_tag = "[$tag_title]";
183 $end_tag = "[/$tag_title]";
184 $instructions = 'Here is a [placeholder] hidden before the start tag' . $start_tag . $instruction_text . $end_tag;
185 $doc_processor = $this->createDocumentProcessorBaseObject();
186
187 // Act
188 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
189
190 // Assert
191 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
192 }
193
199 {
200 // Arrange
201 $instruction_text1 = 'This are the first instructions';
202 $instruction_text2 = 'This are the second instructions\'';
203 $tag_title1 = 'tag1';
204 $start_tag1 = "[$tag_title1]";
205 $end_tag1 = "[/$tag_title1]";
206 $tag_title2 = 'tag2';
207 $start_tag2 = "[$tag_title2]";
208 $end_tag2 = "[/$tag_title2]";
209 $instructions = $start_tag1 . $instruction_text1 . $end_tag1 . $start_tag2 . $instruction_text2 . $end_tag2;
210 $doc_processor = $this->createDocumentProcessorBaseObject();
211
212 // Act
213 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
214
215 // Assert
216 $this->assertEquals($instruction_text1, $parsed_instructions[$tag_title1]);
217 $this->assertEquals($instruction_text2, $parsed_instructions[$tag_title2]);
218 }
219}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...