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