ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilWebDAVMountInstructionsDocumentProcessorBaseTest.php
Go to the documentation of this file.
1 <?php
2 
20 
22 {
24  {
25  return new class () extends ilWebDAVMountInstructionsDocumentProcessorBase {
30  public function processMountInstructions(string $a_raw_mount_instructions): array
31  {
32  return [];
33  }
34  };
35  }
36 
42  {
43  // Arrange
44  $instructions = 'hello world';
45  $doc_processor = $this->createDocumentProcessorBaseObject();
46 
47  // Act
48  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
49 
50  // Assert
51  $this->assertEquals($instructions, $parsed_instructions[0]);
52  }
53 
59  {
60  // Arrange
61  $instructions = 'This is a start [tag] with no end tag';
62  $doc_processor = $this->createDocumentProcessorBaseObject();
63 
64  // Act
65  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
66 
67  // Assert
68  $this->assertEquals($instructions, $parsed_instructions[0]);
69  }
70 
76  {
77  // Arrange
78  $instructions = 'There is no start tag but an end [/tag] in the string';
79  $doc_processor = $this->createDocumentProcessorBaseObject();
80 
81  // Act
82  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
83 
84  // Assert
85  $this->assertEquals($instructions, $parsed_instructions[0]);
86  }
87 
93  {
94  // Arrange
95  $instrunction_text = 'This are the mount Instructions';
96  $tag_title = 'tag';
97  $start_tag = "[$tag_title]";
98  $end_tag = "[/$tag_title]";
99  $instructions = $start_tag . $instrunction_text . $end_tag;
100  $doc_processor = $this->createDocumentProcessorBaseObject();
101 
102  // Act
103  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
104 
105  // Assert
106  $this->assertEquals($instrunction_text, $parsed_instructions[$tag_title]);
107  }
108 
114  {
115  // Arrange
116  $instruction_text = 'This are the mount Instructions';
117  $tag_title = 'tag with spaces';
118  $start_tag = "[$tag_title]";
119  $end_tag = "[/$tag_title]";
120  $instructions = $start_tag . $instruction_text . $end_tag;
121  $doc_processor = $this->createDocumentProcessorBaseObject();
122 
123  // Act
124  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
125 
126  // Assert
127  $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
128  }
129 
135  {
136  // Arrange
137  $instruction_text = 'This are the mount Instructions';
138  $tag_title = 'tag_w!th$pecial"chars?';
139  $start_tag = "[$tag_title]";
140  $end_tag = "[/$tag_title]";
141  $instructions = $start_tag . $instruction_text . $end_tag;
142  $doc_processor = $this->createDocumentProcessorBaseObject();
143 
144  // Act
145  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
146 
147  // Assert
148  $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
149  }
150 
156  ): void {
157  // Arrange
158  $instruction_text = 'This are the mount Instructions';
159  $tag_title = 'tag';
160  $start_tag = "[$tag_title]";
161  $end_tag = "[/$tag_title]";
162  $instructions = 'This will be cut off' . $start_tag . $instruction_text . $end_tag . 'and this of will be cut off as well';
163  $doc_processor = $this->createDocumentProcessorBaseObject();
164 
165  // Act
166  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
167 
168  // Assert
169  $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
170  }
171 
177  {
178  // Arrange
179  $instruction_text = 'This are the mount Instructions';
180  $tag_title = 'tag';
181  $start_tag = "[$tag_title]";
182  $end_tag = "[/$tag_title]";
183  $instructions = 'Here is a [placeholder] hidden before the start tag' . $start_tag . $instruction_text . $end_tag;
184  $doc_processor = $this->createDocumentProcessorBaseObject();
185 
186  // Act
187  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
188 
189  // Assert
190  $this->assertEquals($instruction_text, $parsed_instructions[$tag_title]);
191  }
192 
198  {
199  // Arrange
200  $instruction_text1 = 'This are the first instructions';
201  $instruction_text2 = 'This are the second instructions\'';
202  $tag_title1 = 'tag1';
203  $start_tag1 = "[$tag_title1]";
204  $end_tag1 = "[/$tag_title1]";
205  $tag_title2 = 'tag2';
206  $start_tag2 = "[$tag_title2]";
207  $end_tag2 = "[/$tag_title2]";
208  $instructions = $start_tag1 . $instruction_text1 . $end_tag1 . $start_tag2 . $instruction_text2 . $end_tag2;
209  $doc_processor = $this->createDocumentProcessorBaseObject();
210 
211  // Act
212  $parsed_instructions = $doc_processor->parseInstructionsToAssocArray($instructions);
213 
214  // Assert
215  $this->assertEquals($instruction_text1, $parsed_instructions[$tag_title1]);
216  $this->assertEquals($instruction_text2, $parsed_instructions[$tag_title2]);
217  }
218 }