ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlStructureMapperTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6 
8 
14 class ilCtrlStructureMapperTest extends TestCase
15 {
16  public function testStructureMapperWithEmptyArray(): void
17  {
18  $mapper = new ilCtrlStructureMapper([]);
19  $this->assertEmpty($mapper->getStructure());
20  }
21 
23  {
24  $expected_values = ['entry0', 'entry1', 'entry2'];
25  $mapper = new ilCtrlStructureMapper($expected_values);
26 
27  $this->assertEmpty($mapper->getStructure());
28  }
29 
31  {
32  $mapper = new ilCtrlStructureMapper([
33  'key0' => 'entry0',
34  'key1' => 'entry1',
35  'key2' => 'entry2'
36  ]);
37 
38  $this->assertEmpty($mapper->getStructure());
39  }
40 
41  public function testStructureMapperWithEmptyClassData(): void
42  {
43  $expected_values = [
44  'key0' => [],
45  'key1' => [],
46  'key2' => []
47  ];
48 
49  $mapper = new ilCtrlStructureMapper($expected_values);
50 
51  $this->assertEquals(
52  $expected_values,
53  $mapper->getStructure()
54  );
55  }
56 
57  public function testStructureMapperWithStructureArray(): void
58  {
59  $mapper = new ilCtrlStructureMapper([
60  'class0' => [
62  'class1',
63  ],
65  ],
66  'class1' => [
69  'class2',
70  ],
71  ],
72  'class2' => [
75  ]
76  ]);
77 
78  $this->assertEquals(
79  [
80  'class0' => [
82  'class1',
83  ],
85  ],
86  'class1' => [
89  'class2',
90  'class0',
91  ],
92  ],
93  'class2' => [
95  'class1',
96  ],
98  ]
99  ],
100  $mapper->getStructure()
101  );
102  }
103 
105  {
106  $mapper = new ilCtrlStructureMapper([
107  'class0' => [
109  'class1',
110  ],
111  ],
112  'class1' => [
114  'class2',
115  ],
116  ],
117  'class2' => []
118  ]);
119 
120  $this->assertEquals(
121  [
122  'class0' => [
124  'class1',
125  ],
126  ],
127  'class1' => [
129  'class2',
130  'class0',
131  ],
132  ],
133  'class2' => [
135  'class1',
136  ],
137  ]
138  ],
139  $mapper->getStructure()
140  );
141  }
142 
144  {
145  $mapper = new ilCtrlStructureMapper([
146  'class1' => [
148  'class2',
149  ],
150  ],
151  ]);
152 
153  $this->assertEquals(
154  [
155  'class1' => [
157  ]
158  ],
159  $mapper->getStructure()
160  );
161  }
162 
164  {
165  $mapper = new ilCtrlStructureMapper([
166  'class1' => [
168  0 => 'class3',
169  1 => 'class2',
170  ],
171  ],
172  'class2' => [],
173  ]);
174 
175  $this->assertEquals(
176  [
177  'class1' => [
179  0 => 'class2',
180  ],
181  ],
182  'class2' => [
184  0 => 'class1',
185  ],
186  ],
187  ],
188  $mapper->getStructure()
189  );
190  }
191 
192  public function testStructureMapperWithMixedArray(): void
193  {
194  $mapper = new ilCtrlStructureMapper([
195  'class1' => [],
196  'class2' => false,
197  3 => [
199  'class1',
200  ],
201  ],
202  'class3' => [
204  'class1',
205  'class2',
206  ],
207  ],
208  'class4' => [
210  3
211  ],
212  ],
213  ]);
214 
215  $this->assertEquals(
216  [
217  'class1' => [
219  'class3',
220  ],
221  ],
222  'class3' => [
224  'class1',
225  ],
226  ],
227  'class4' => [
229  ],
230  ],
231  $mapper->getStructure()
232  );
233  }
234 }
Class ilCtrlStructureMapper.
Class ilCtrlStructureMapperTest.