ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCtrlStructureMapperTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 {
30  public function testStructureMapperWithEmptyArray(): void
31  {
32  $mapper = new ilCtrlStructureMapper([]);
33  $this->assertEmpty($mapper->getStructure());
34  }
35 
37  {
38  $expected_values = ['entry0', 'entry1', 'entry2'];
39  $mapper = new ilCtrlStructureMapper($expected_values);
40 
41  $this->assertEmpty($mapper->getStructure());
42  }
43 
45  {
46  $mapper = new ilCtrlStructureMapper([
47  'key0' => 'entry0',
48  'key1' => 'entry1',
49  'key2' => 'entry2'
50  ]);
51 
52  $this->assertEmpty($mapper->getStructure());
53  }
54 
55  public function testStructureMapperWithEmptyClassData(): void
56  {
57  $expected_values = [
58  'key0' => [],
59  'key1' => [],
60  'key2' => []
61  ];
62 
63  $mapper = new ilCtrlStructureMapper($expected_values);
64 
65  $this->assertEquals(
66  $expected_values,
67  $mapper->getStructure()
68  );
69  }
70 
71  public function testStructureMapperWithStructureArray(): void
72  {
73  $mapper = new ilCtrlStructureMapper([
74  'class0' => [
76  'class1',
77  ],
79  ],
80  'class1' => [
83  'class2',
84  ],
85  ],
86  'class2' => [
89  ]
90  ]);
91 
92  $this->assertEquals(
93  [
94  'class0' => [
96  'class1',
97  ],
99  ],
100  'class1' => [
103  'class2',
104  'class0',
105  ],
106  ],
107  'class2' => [
109  'class1',
110  ],
112  ]
113  ],
114  $mapper->getStructure()
115  );
116  }
117 
119  {
120  $mapper = new ilCtrlStructureMapper([
121  'class0' => [
123  'class1',
124  ],
125  ],
126  'class1' => [
128  'class2',
129  ],
130  ],
131  'class2' => []
132  ]);
133 
134  $this->assertEquals(
135  [
136  'class0' => [
138  'class1',
139  ],
140  ],
141  'class1' => [
143  'class2',
144  'class0',
145  ],
146  ],
147  'class2' => [
149  'class1',
150  ],
151  ]
152  ],
153  $mapper->getStructure()
154  );
155  }
156 
158  {
159  $mapper = new ilCtrlStructureMapper([
160  'class1' => [
162  'class2',
163  ],
164  ],
165  ]);
166 
167  $this->assertEquals(
168  [
169  'class1' => [
171  ]
172  ],
173  $mapper->getStructure()
174  );
175  }
176 
178  {
179  $mapper = new ilCtrlStructureMapper([
180  'class1' => [
182  0 => 'class3',
183  1 => 'class2',
184  ],
185  ],
186  'class2' => [],
187  ]);
188 
189  $this->assertEquals(
190  [
191  'class1' => [
193  0 => 'class2',
194  ],
195  ],
196  'class2' => [
198  0 => 'class1',
199  ],
200  ],
201  ],
202  $mapper->getStructure()
203  );
204  }
205 
206  public function testStructureMapperWithMixedArray(): void
207  {
208  $mapper = new ilCtrlStructureMapper([
209  'class1' => [],
210  'class2' => false,
211  3 => [
213  'class1',
214  ],
215  ],
216  'class3' => [
218  'class1',
219  'class2',
220  ],
221  ],
222  'class4' => [
224  3
225  ],
226  ],
227  ]);
228 
229  $this->assertEquals(
230  [
231  'class1' => [
233  'class3',
234  ],
235  ],
236  'class3' => [
238  'class1',
239  ],
240  ],
241  'class4' => [
243  ],
244  ],
245  $mapper->getStructure()
246  );
247  }
248 }
Class ilCtrlStructureMapper.
Class ilCtrlStructureMapperTest.