ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWebDAVMountInstructionsDocumentProcessorBaseTest.php
Go to the documentation of this file.
1<?php
2
3use \PHPUnit\Framework\TestCase;
4use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
5
7{
9 {
10 return new class extends ilWebDAVMountInstructionsDocumentProcessorBase {
11 public function processMountInstructions(string $a_raw_mount_instructions) : array
12 {
13 return null;
14 }
15 };
16 }
17
23 {
24 // Arrange
25 $instructions = 'hello world';
26 $doc_processor = $this->createDocumentProcessorBaseObject();
27
28 // Act
29 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
30
31 // Assert
32 $this->assertEquals($instructions, $parsed_instructions[0]);
33 }
34
40 {
41 // Arrange
42 $instructions = 'This is a start [tag] with no end tag';
43 $doc_processor = $this->createDocumentProcessorBaseObject();
44
45 // Act
46 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
47
48 // Assert
49 $this->assertEquals($instructions, $parsed_instructions[0]);
50 }
51
57 {
58 // Arrange
59 $instructions = 'There is no start tag but an end [/tag] in the string';
60 $doc_processor = $this->createDocumentProcessorBaseObject();
61
62 // Act
63 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
64
65 // Assert
66 $this->assertEquals($instructions, $parsed_instructions[0]);
67 }
68
74 {
75 // Arrange
76 $instrunction_text = 'This are the mount Instructions';
77 $tag_title = 'tag';
78 $start_tag = "[$tag_title]";
79 $end_tag = "[/$tag_title]";
80 $instructions = $start_tag . $instrunction_text . $end_tag;
81 $doc_processor = $this->createDocumentProcessorBaseObject();
82
83 // Act
84 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
85
86 // Assert
87 $this->assertEquals($instrunction_text, $parsed_instructions[$tag_title]);
88 }
89
95 {
96 // Arrange
97 $instruction_text = 'This are the mount Instructions';
98 $tag_title = 'tag with spaces';
99 $start_tag = "[$tag_title]";
100 $end_tag = "[/$tag_title]";
101 $instructions = $start_tag . $instruction_text . $end_tag;
102 $doc_processor = $this->createDocumentProcessorBaseObject();
103
104 // Act
105 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
106
107 // Assert
108 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
109 }
110
116 {
117 // Arrange
118 $instruction_text = 'This are the mount Instructions';
119 $tag_title = 'tag_w!th$pecial"chars?';
120 $start_tag = "[$tag_title]";
121 $end_tag = "[/$tag_title]";
122 $instructions = $start_tag . $instruction_text . $end_tag;
123 $doc_processor = $this->createDocumentProcessorBaseObject();
124
125 // Act
126 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
127
128 // Assert
129 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
130 }
131
137 {
138 // Arrange
139 $instruction_text = 'This are the mount Instructions';
140 $tag_title = 'tag';
141 $start_tag = "[$tag_title]";
142 $end_tag = "[/$tag_title]";
143 $instructions = 'This will be cut off' . $start_tag . $instruction_text . $end_tag . 'and this of will be cut off as well';
144 $doc_processor = $this->createDocumentProcessorBaseObject();
145
146 // Act
147 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
148
149 // Assert
150 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
151 }
152
158 {
159 // Arrange
160 $instruction_text = 'This are the mount Instructions';
161 $tag_title = 'tag';
162 $start_tag = "[$tag_title]";
163 $end_tag = "[/$tag_title]";
164 $instructions = 'Here is a [placeholder] hidden before the start tag' . $start_tag . $instruction_text . $end_tag;
165 $doc_processor = $this->createDocumentProcessorBaseObject();
166
167 // Act
168 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
169
170 // Assert
171 $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
172 }
173
179 {
180 // Arrange
181 $instruction_text1 = 'This are the first instructions';
182 $instruction_text2 = 'This are the second instructions\'';
183 $tag_title1 = 'tag1';
184 $start_tag1 = "[$tag_title1]";
185 $end_tag1 = "[/$tag_title1]";
186 $tag_title2 = 'tag2';
187 $start_tag2 = "[$tag_title2]";
188 $end_tag2 = "[/$tag_title2]";
189 $instructions = $start_tag1 . $instruction_text1 . $end_tag1 . $start_tag2 . $instruction_text2 . $end_tag2;
190 $doc_processor = $this->createDocumentProcessorBaseObject();
191
192 // Act
193 $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
194
195 // Assert
196 $this->assertEquals($instruction_text1, $parsed_instructions[$tag_title1]);
197 $this->assertEquals($instruction_text2, $parsed_instructions[$tag_title2]);
198 }
199}
An exception for terminatinating execution or to throw for unit testing.