ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
MainSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
31 
33 {
37  public function testThrowOnDifferentTestId(int $IO): void
38  {
39  $test_settings = $this->createConfiguredMock(TestSettings::class, ['getTestId' => $IO]);
40  $main_settings = new MainSettings(
41  $IO,
42  0,
43  $this->createConfiguredMock(SettingsGeneral::class, ['getTestId' => $IO]),
44  $this->createConfiguredMock(SettingsIntroduction::class, ['getTestId' => $IO]),
45  $this->createConfiguredMock(SettingsAccess::class, ['getTestId' => $IO]),
46  $this->createConfiguredMock(SettingsTestBehaviour::class, ['getTestId' => $IO]),
47  $this->createConfiguredMock(SettingsQuestionBehaviour::class, ['getTestId' => $IO]),
48  $this->createConfiguredMock(SettingsParticipantFunctionality::class, ['getTestId' => $IO]),
49  $this->createConfiguredMock(SettingsFinishing::class, ['getTestId' => $IO]),
50  $this->createConfiguredMock(SettingsAdditional::class, ['getTestId' => $IO])
51  );
52 
53  $output = self::callMethod($main_settings, 'throwOnDifferentTestId', [$test_settings]);
54 
55  $this->assertNull($output);
56  }
57 
58  public static function throwOnDifferentTestIdDataProvider(): array
59  {
60  return [
61  [-1],
62  [0],
63  [1]
64  ];
65  }
66 
70  public function testThrowOnDifferentTestIdException(array $input): void
71  {
72  $test_settings = $this->createMock(TestSettings::class);
73  $test_settings->method('getTestId')->willReturn($input['test_id_1']);
74  $main_settings = new MainSettings(
75  $input['test_id_2'],
76  0,
77  $this->createConfiguredMock(SettingsGeneral::class, ['getTestId' => $input['test_id_2']]),
78  $this->createConfiguredMock(SettingsIntroduction::class, ['getTestId' => $input['test_id_2']]),
79  $this->createConfiguredMock(SettingsAccess::class, ['getTestId' => $input['test_id_2']]),
80  $this->createConfiguredMock(SettingsTestBehaviour::class, ['getTestId' => $input['test_id_2']]),
81  $this->createConfiguredMock(SettingsQuestionBehaviour::class, ['getTestId' => $input['test_id_2']]),
82  $this->createConfiguredMock(SettingsParticipantFunctionality::class, ['getTestId' => $input['test_id_2']]),
83  $this->createConfiguredMock(SettingsFinishing::class, ['getTestId' => $input['test_id_2']]),
84  $this->createConfiguredMock(SettingsAdditional::class, ['getTestId' => $input['test_id_2']])
85  );
86  $this->expectException(LogicException::class);
87  self::callMethod($main_settings, 'throwOnDifferentTestId', [$test_settings]);
88  }
89 
90  public static function throwOnDifferentTestIdExceptionDataProvider(): array
91  {
92  return [
93  [['test_id_1' => -1, 'test_id_2' => 0]],
94  [['test_id_1' => 0, 'test_id_2' => 1]],
95  [['test_id_1' => 1, 'test_id_2' => -1]]
96  ];
97  }
98 
102  public function testGetAndWithTestId(int $IO): void
103  {
104  $main_settings = (new MainSettings(
105  0,
106  0,
107  $this->createConfiguredMock(
108  SettingsGeneral::class,
109  ['withTestId' => $this->createMock(SettingsGeneral::class)]
110  ),
111  $this->createConfiguredMock(
112  SettingsIntroduction::class,
113  ['withTestId' => $this->createMock(SettingsIntroduction::class)]
114  ),
115  $this->createConfiguredMock(
116  SettingsAccess::class,
117  ['withTestId' => $this->createMock(SettingsAccess::class)]
118  ),
119  $this->createConfiguredMock(
120  SettingsTestBehaviour::class,
121  ['withTestId' => $this->createMock(SettingsTestBehaviour::class)]
122  ),
123  $this->createConfiguredMock(
124  SettingsQuestionBehaviour::class,
125  ['withTestId' => $this->createMock(SettingsQuestionBehaviour::class)]
126  ),
127  $this->createConfiguredMock(
128  SettingsParticipantFunctionality::class,
129  ['withTestId' => $this->createMock(SettingsParticipantFunctionality::class)]
130  ),
131  $this->createConfiguredMock(
132  SettingsFinishing::class,
133  ['withTestId' => $this->createMock(SettingsFinishing::class)]
134  ),
135  $this->createConfiguredMock(
136  SettingsAdditional::class,
137  ['withTestId' => $this->createMock(SettingsAdditional::class)]
138  )
139  ))->withTestId($IO);
140 
141 
142  $this->assertInstanceOf(MainSettings::class, $main_settings);
143  $this->assertEquals($IO, $main_settings->getTestId());
144  }
145 
146  public static function getAndWithTestIdDataProvider(): array
147  {
148  return [
149  [-1],
150  [0],
151  [1]
152  ];
153  }
154 
158  public function testGetAndWithGeneralSettings(\Closure $IO): void
159  {
160  $IO = $IO($this);
161  $main_settings = (new MainSettings(
162  0,
163  0,
164  $this->createMock(SettingsGeneral::class),
165  $this->createMock(SettingsIntroduction::class),
166  $this->createMock(SettingsAccess::class),
167  $this->createMock(SettingsTestBehaviour::class),
168  $this->createMock(SettingsQuestionBehaviour::class),
169  $this->createMock(SettingsParticipantFunctionality::class),
170  $this->createMock(SettingsFinishing::class),
171  $this->createMock(SettingsAdditional::class)
172  ))->withGeneralSettings($IO);
173 
174  $this->assertInstanceOf(MainSettings::class, $main_settings);
175  $this->assertEquals($IO, $main_settings->getGeneralSettings());
176  }
177 
178  public static function getAndWithGeneralSettingsDataProvider(): array
179  {
180  return [[
181  static fn(self $test_case): SettingsGeneral =>
182  $test_case->createMock(SettingsGeneral::class)
183  ]];
184  }
185 
189  public function testGetAndWithIntroductionSettings(\Closure $IO): void
190  {
191  $IO = $IO($this);
192  $main_settings = (new MainSettings(
193  0,
194  0,
195  $this->createMock(SettingsGeneral::class),
196  $this->createMock(SettingsIntroduction::class),
197  $this->createMock(SettingsAccess::class),
198  $this->createMock(SettingsTestBehaviour::class),
199  $this->createMock(SettingsQuestionBehaviour::class),
200  $this->createMock(SettingsParticipantFunctionality::class),
201  $this->createMock(SettingsFinishing::class),
202  $this->createMock(SettingsAdditional::class)
203  ))->withIntroductionSettings($IO);
204 
205  $this->assertInstanceOf(MainSettings::class, $main_settings);
206  $this->assertEquals($IO, $main_settings->getIntroductionSettings());
207  }
208 
209  public static function getAndWithIntroductionSettingsDataProvider(): array
210  {
211  return [[
212  static fn(self $test_case): SettingsIntroduction =>
213  $test_case->createMock(SettingsIntroduction::class)
214  ]];
215  }
216 
220  public function testGetAndWithAccessSettings(\Closure $IO): void
221  {
222  $IO = $IO($this);
223  $main_settings = (new MainSettings(
224  0,
225  0,
226  $this->createMock(SettingsGeneral::class),
227  $this->createMock(SettingsIntroduction::class),
228  $this->createMock(SettingsAccess::class),
229  $this->createMock(SettingsTestBehaviour::class),
230  $this->createMock(SettingsQuestionBehaviour::class),
231  $this->createMock(SettingsParticipantFunctionality::class),
232  $this->createMock(SettingsFinishing::class),
233  $this->createMock(SettingsAdditional::class)
234  ))->withAccessSettings($IO);
235 
236  $this->assertInstanceOf(MainSettings::class, $main_settings);
237  $this->assertEquals($IO, $main_settings->getAccessSettings());
238  }
239 
240  public static function getAndWithAccessSettingsDataProvider(): array
241  {
242  return [[
243  static fn(self $test_case): SettingsAccess =>
244  $test_case->createMock(SettingsAccess::class)
245  ]];
246  }
247 
251  public function testGetAndWithTestBehaviourSettings(\Closure $IO): void
252  {
253  $IO = $IO($this);
254  $main_settings = (new MainSettings(
255  0,
256  0,
257  $this->createMock(SettingsGeneral::class),
258  $this->createMock(SettingsIntroduction::class),
259  $this->createMock(SettingsAccess::class),
260  $this->createMock(SettingsTestBehaviour::class),
261  $this->createMock(SettingsQuestionBehaviour::class),
262  $this->createMock(SettingsParticipantFunctionality::class),
263  $this->createMock(SettingsFinishing::class),
264  $this->createMock(SettingsAdditional::class)
265  ))->withTestBehaviourSettings($IO);
266 
267  $this->assertInstanceOf(MainSettings::class, $main_settings);
268  $this->assertEquals($IO, $main_settings->getTestBehaviourSettings());
269  }
270 
271  public static function getAndWithTestBehaviourSettingsDataProvider(): array
272  {
273  return [[
274  static fn(self $test_case): SettingsTestBehaviour =>
275  $test_case->createMock(SettingsTestBehaviour::class)
276  ]];
277  }
278 
283  {
284  $IO = $IO($this);
285  $main_settings = (new MainSettings(
286  0,
287  0,
288  $this->createMock(SettingsGeneral::class),
289  $this->createMock(SettingsIntroduction::class),
290  $this->createMock(SettingsAccess::class),
291  $this->createMock(SettingsTestBehaviour::class),
292  $this->createMock(SettingsQuestionBehaviour::class),
293  $this->createMock(SettingsParticipantFunctionality::class),
294  $this->createMock(SettingsFinishing::class),
295  $this->createMock(SettingsAdditional::class)
296  ))->withQuestionBehaviourSettings($IO);
297 
298  $this->assertInstanceOf(MainSettings::class, $main_settings);
299  $this->assertEquals($IO, $main_settings->getQuestionBehaviourSettings());
300  }
301 
302  public static function getAndWithQuestionBehaviourSettingsDataProvider(): array
303  {
304  return [[
305  static fn(self $test_case): SettingsQuestionBehaviour =>
306  $test_case->createMock(SettingsQuestionBehaviour::class)
307  ]];
308  }
309 
314  {
315  $IO = $IO($this);
316  $main_settings = (new MainSettings(
317  0,
318  0,
319  $this->createMock(SettingsGeneral::class),
320  $this->createMock(SettingsIntroduction::class),
321  $this->createMock(SettingsAccess::class),
322  $this->createMock(SettingsTestBehaviour::class),
323  $this->createMock(SettingsQuestionBehaviour::class),
324  $this->createMock(SettingsParticipantFunctionality::class),
325  $this->createMock(SettingsFinishing::class),
326  $this->createMock(SettingsAdditional::class)
327  ))->withParticipantFunctionalitySettings($IO);
328 
329  $this->assertInstanceOf(MainSettings::class, $main_settings);
330  $this->assertEquals($IO, $main_settings->getParticipantFunctionalitySettings());
331  }
332 
334  {
335  return [[
336  static fn(self $test_case): SettingsParticipantFunctionality =>
337  $test_case->createMock(SettingsParticipantFunctionality::class)
338  ]];
339  }
340 
344  public function testGetAndWithFinishingSettings(\Closure $IO): void
345  {
346  $IO = $IO($this);
347  $main_settings = (new MainSettings(
348  0,
349  0,
350  $this->createMock(SettingsGeneral::class),
351  $this->createMock(SettingsIntroduction::class),
352  $this->createMock(SettingsAccess::class),
353  $this->createMock(SettingsTestBehaviour::class),
354  $this->createMock(SettingsQuestionBehaviour::class),
355  $this->createMock(SettingsParticipantFunctionality::class),
356  $this->createMock(SettingsFinishing::class),
357  $this->createMock(SettingsAdditional::class)
358  ))->withFinishingSettings($IO);
359 
360  $this->assertInstanceOf(MainSettings::class, $main_settings);
361  $this->assertEquals($IO, $main_settings->getFinishingSettings());
362  }
363 
364  public static function getAndWithFinishingSettingsDataProvider(): array
365  {
366  return [[
367  static fn(self $test_case): SettingsFinishing =>
368  $test_case->createMock(SettingsFinishing::class)
369  ]];
370  }
371 
375  public function testGetAndWithAdditionalSettings(\Closure $IO): void
376  {
377  $IO = $IO($this);
378  $main_settings = (new MainSettings(
379  0,
380  0,
381  $this->createMock(SettingsGeneral::class),
382  $this->createMock(SettingsIntroduction::class),
383  $this->createMock(SettingsAccess::class),
384  $this->createMock(SettingsTestBehaviour::class),
385  $this->createMock(SettingsQuestionBehaviour::class),
386  $this->createMock(SettingsParticipantFunctionality::class),
387  $this->createMock(SettingsFinishing::class),
388  $this->createMock(SettingsAdditional::class)
389  ))->withAdditionalSettings($IO);
390 
391  $this->assertInstanceOf(MainSettings::class, $main_settings);
392  $this->assertEquals($IO, $main_settings->getAdditionalSettings());
393  }
394 
395  public static function getAndWithAdditionalSettingsDataProvider(): array
396  {
397  return [[
398  static fn(self $test_case): SettingsAdditional =>
399  $test_case->createMock(SettingsAdditional::class)
400  ]];
401  }
402 }
static getAndWithTestBehaviourSettingsDataProvider()
testGetAndWithAdditionalSettings(\Closure $IO)
getAndWithAdditionalSettingsDataProvider
static getAndWithParticipantFunctionalitySettingsDataProvider()
static getAndWithIntroductionSettingsDataProvider()
testThrowOnDifferentTestId(int $IO)
throwOnDifferentTestIdDataProvider
static getAndWithFinishingSettingsDataProvider()
static throwOnDifferentTestIdExceptionDataProvider()
testGetAndWithAccessSettings(\Closure $IO)
getAndWithAccessSettingsDataProvider
static getAndWithAccessSettingsDataProvider()
testGetAndWithTestId(int $IO)
getAndWithTestIdDataProvider
static getAndWithGeneralSettingsDataProvider()
static getAndWithAdditionalSettingsDataProvider()
static getAndWithTestIdDataProvider()
testGetAndWithParticipantFunctionalitySettings(\Closure $IO)
getAndWithParticipantFunctionalitySettingsDataProvider
testGetAndWithIntroductionSettings(\Closure $IO)
getAndWithIntroductionSettingsDataProvider
static throwOnDifferentTestIdDataProvider()
testGetAndWithFinishingSettings(\Closure $IO)
getAndWithFinishingSettingsDataProvider
static getAndWithQuestionBehaviourSettingsDataProvider()
testGetAndWithTestBehaviourSettings(\Closure $IO)
getAndWithTestBehaviourSettingsDataProvider
testGetAndWithQuestionBehaviourSettings(\Closure $IO)
getAndWithQuestionBehaviourSettingsDataProvider
testGetAndWithGeneralSettings(\Closure $IO)
getAndWithGeneralSettingsDataProvider
testThrowOnDifferentTestIdException(array $input)
throwOnDifferentTestIdExceptionDataProvider