ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MarkSchemaTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
32 protected $backupGlobals = false;
33
34 protected function setUp(): void
35 {
36 parent::setUp();
37
38 $this->ass_mark_schema = new MarkSchema(0);
39 }
40
44 public function testConstructor()
45 {
46 // Arrange
47 $expected = is_array([]);
48
49 // Act
50 $actual = is_array($this->ass_mark_schema->getMarkSteps());
51
52 // Assert
53 $this->assertEquals(
54 $actual,
55 $expected,
56 "Constructor failed, mark_steps not an array."
57 );
58 }
59
64 {
65 // Arrange
66
67 $txt_failed_short = "failed";
68 $txt_failed_official = "failed";
69 $percentage_failed = 0;
70 $failed_passed = false;
71 $txt_passed_short = "passed";
72 $txt_passed_official = "passed";
73 $percentage_passed = 50;
74 $passed_passed = true;
75
76 // Act
77 $mark_schema = $this->ass_mark_schema->createSimpleSchema();
78 $marks = $mark_schema->getMarkSteps();
79
80 $failed = $marks[0];
81 $passed = $marks[1];
82
83 // Assert
84 $this->assertEquals(
85 $failed->getShortName(),
86 $txt_failed_short,
87 'Failed on $txt_failed_short'
88 );
89 $this->assertEquals(
90 $failed->getOfficialName(),
91 $txt_failed_official,
92 'Failed on $txt_failed_official'
93 );
94 $this->assertEquals(
95 $failed->getMinimumLevel(),
96 $percentage_failed,
97 'Failed on $percentage_failed'
98 );
99 $this->assertEquals(
100 $failed->getPassed(),
101 $failed_passed,
102 'Failed on $failed_passed'
103 );
104
105 $this->assertEquals(
106 $passed->getShortName(),
107 $txt_passed_short,
108 'Failed on $txt_passed_short'
109 );
110 $this->assertEquals(
111 $passed->getOfficialName(),
112 $txt_passed_official,
113 'Failed on $txt_passed_official'
114 );
115 $this->assertEquals(
116 $passed->getMinimumLevel(),
117 $percentage_passed,
118 'Failed on $percetage_passed'
119 );
120 $this->assertEquals(
121 $passed->getPassed(),
122 $passed_passed,
123 'Failed on $passed_passed'
124 );
125 }
126
131 {
132 // Arrange
133 $txt_failed_short = "failed";
134 $txt_failed_official = "failed";
135 $percentage_failed = 0;
136 $failed_passed = false;
137 $txt_passed_short = "passed";
138 $txt_passed_official = "passed";
139 $percentage_passed = 50;
140 $passed_passed = true;
141
142 // Act
143 $mark_schema = $this->ass_mark_schema->createSimpleSchema(
144 $txt_failed_short,
145 $txt_failed_official,
146 $percentage_failed,
147 $failed_passed,
148 $txt_passed_short,
149 $txt_passed_official,
150 $percentage_passed,
151 $passed_passed
152 );
153
154 $marks = $mark_schema->getMarkSteps();
155
156 $failed = $marks[0];
157 $passed = $marks[1];
158
159 // Assert
160 $this->assertEquals(
161 $failed->getShortName(),
162 $txt_failed_short,
163 'Failed on $txt_failed_short'
164 );
165 $this->assertEquals(
166 $failed->getOfficialName(),
167 $txt_failed_official,
168 'Failed on $txt_failed_official'
169 );
170 $this->assertEquals(
171 $failed->getMinimumLevel(),
172 $percentage_failed,
173 'Failed on $percentage_failed'
174 );
175 $this->assertEquals(
176 $failed->getPassed(),
177 $failed_passed,
178 'Failed on $failed_passed'
179 );
180
181 $this->assertEquals(
182 $passed->getShortName(),
183 $txt_passed_short,
184 'Failed on $txt_passed_short'
185 );
186 $this->assertEquals(
187 $passed->getOfficialName(),
188 $txt_passed_official,
189 'Failed on $txt_passed_official'
190 );
191 $this->assertEquals(
192 $passed->getMinimumLevel(),
193 $percentage_passed,
194 'Failed on $percetage_passed'
195 );
196 $this->assertEquals(
197 $passed->getPassed(),
198 $passed_passed,
199 'Failed on $passed_passed'
200 );
201 }
202
203 #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
204 public function testSaveToDb_regular()
205 {
206 /*
207 // Arrange
208 $ildb_stub = $this->createMock('ilDBInterface');
209
210 $ildb_stub->expects($this->any())
211 ->method('query')
212 ->will($this->returnValue('foo'));
213
214 $ildb_stub->expects($this->any())
215 ->method('numRows')
216 ->will($this->returnValue(1));
217
218 $db_result_1 = array('cmi_node_id' => 8);
219 $db_result_2 = array('cmi_node_id' => 10);
220 $db_result_3 = array('cmi_node_id' => 12);
221 $db_result_4 = array('cmi_node_id' => 14);
222
223 $ildb_stub->expects($this->any())
224 ->method('fetchAssoc')
225 ->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
226 */
227 }
228}
A class defining mark schemas for assessment test objects.
Definition: MarkSchema.php:36
Unit tests for single choice questions.
testConstructor()
Test constructor.
testCreateSimpleSchemaCustom()
Test for createSimpleSchema using custom values.
testCreateSimpleSchemaDefaults()
Test for createSimpleSchema using defaults.
MarkSchema $ass_mark_schema
Class ilTestBaseClass.