ILIAS  release_8 Revision v8.24
ilQTIAssessmentcontrolTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22use PHPUnit\Framework\TestCase;
23
24class ilQTIAssessmentcontrolTest extends TestCase
25{
27 {
28 $instance = new ilQTIAssessmentcontrol();
29
30 $this->assertInstanceOf(ilQTIAssessmentcontrol::class, $instance);
31
32 return $instance;
33 }
34
38 public function testGetView(ilQTIAssessmentcontrol $instance): void
39 {
40 $this->assertEquals('All', $instance->getView());
41 }
42
47 public function testSetViewValid(string $view): void
48 {
49 $instance = new ilQTIAssessmentcontrol();
50 $instance->setView($view);
51 $this->assertEquals($view, $instance->getView());
52 }
53
57 public function testSetViewInvalid(): void
58 {
59 $instance = new ilQTIAssessmentcontrol();
60 $instance->setView('Some random content.');
61 $this->assertEquals('All', $instance->getView());
62 }
63
68 public function testSwitchInitializeValue(string $suffix): void
69 {
70 $instance = new ilQTIAssessmentcontrol();
71 $get = 'get' . ucfirst($suffix);
72
73 $this->assertEquals('', $instance->$get());
74 }
75
80 public function testSwitchValuesConsideredAsYes(string $suffix): void
81 {
82 $instance = new ilQTIAssessmentcontrol();
83 $get = 'get' . ucfirst($suffix);
84 $set = 'set' . ucfirst($suffix);
85
86 $consideredAsYes = ['Yes', 'yes', 'no', '', 'Some random thing.'];
87 foreach ($consideredAsYes as $value) {
88 $instance->$set($value);
89 $this->assertEquals('Yes', $instance->$get());
90 }
91 }
92
93
98 public function testSwitchValuesConsideredAsNo(string $suffix): void
99 {
100 $instance = new ilQTIAssessmentcontrol();
101 $get = 'get' . ucfirst($suffix);
102 $set = 'set' . ucfirst($suffix);
103
104 $instance->$set('No');
105 $this->assertEquals('No', $instance->$get());
106 }
107
108 public function validViews(): array
109 {
110 return [
111 ['Administrator'],
112 ['AdminAuthority'],
113 ['Assessor'],
114 ['Author'],
115 ['Candidate'],
116 ['InvigilatorProctor'],
117 ['Psychometrician'],
118 ['Scorer'],
119 ['Tutor'],
120 ];
121 }
122
123 public function switches(): array
124 {
125 return [
126 ['hintswitch'],
127 ['solutionswitch'],
128 ['feedbackswitch'],
129 ];
130 }
131}
testSwitchValuesConsideredAsYes(string $suffix)
@dataProvider switches @depends testConstruct
testSwitchInitializeValue(string $suffix)
@dataProvider switches @depends testConstruct
testSetViewInvalid()
@depends testSetViewValid
testGetView(ilQTIAssessmentcontrol $instance)
@depends testConstruct
testSwitchValuesConsideredAsNo(string $suffix)
@dataProvider switches @depends testConstruct
testSetViewValid(string $view)
@dataProvider validViews @depends testGetView