ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilassMarkSchemaTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
14{
15 protected $backupGlobals = false;
16
17 protected function setUp()
18 {
19 if (defined('ILIAS_PHPUNIT_CONTEXT')) {
20 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
21 ilUnitUtil::performInitialisation();
22 } else {
23 chdir(dirname(__FILE__));
24 chdir('../../../');
25 }
26 // Arrange
27 include_once './Modules/Test/classes/class.assMarkSchema.php';
28 $this->ass_mark_schema = new ASS_MarkSchema();
29 }
30
34 public function testConstructor()
35 {
36 // Arrange
37 $expected = is_array(array());
38
39 // Act
40 $actual = is_array($this->ass_mark_schema->mark_steps);
41
42 // Assert
43 $this->assertEquals(
44 $actual,
45 $expected,
46 "Constructor failed, mark_steps not an array."
47 );
48 }
49
54 {
55 // Arrange
56
57
58 $txt_failed_short = "failed";
59 $txt_failed_official = "failed";
60 $percentage_failed = 0;
61 $failed_passed = 0;
62 $txt_passed_short = "passed";
63 $txt_passed_official = "passed";
64 $percentage_passed = 50;
65 $passed_passed = 1;
66
67 // Act
68 $this->ass_mark_schema->createSimpleSchema();
69 $marks = $this->ass_mark_schema->mark_steps;
70
71 $failed = $marks[0];
72 $passed = $marks[1];
73
74 // Assert
75 $this->assertEquals(
76 $failed->getShortName(),
77 $txt_failed_short,
78 'Failed on $txt_failed_short'
79 );
80 $this->assertEquals(
81 $failed->getOfficialName(),
82 $txt_failed_official,
83 'Failed on $txt_failed_official'
84 );
85 $this->assertEquals(
86 $failed->getMinimumLevel(),
87 $percentage_failed,
88 'Failed on $percentage_failed'
89 );
90 $this->assertEquals(
91 $failed->getPassed(),
92 $failed_passed,
93 'Failed on $failed_passed'
94 );
95
96 $this->assertEquals(
97 $passed->getShortName(),
98 $txt_passed_short,
99 'Failed on $txt_passed_short'
100 );
101 $this->assertEquals(
102 $passed->getOfficialName(),
103 $txt_passed_official,
104 'Failed on $txt_passed_official'
105 );
106 $this->assertEquals(
107 $passed->getMinimumLevel(),
108 $percentage_passed,
109 'Failed on $percetage_passed'
110 );
111 $this->assertEquals(
112 $passed->getPassed(),
113 $passed_passed,
114 'Failed on $passed_passed'
115 );
116 }
117
122 {
123 // Arrange
124 $txt_failed_short = "failed";
125 $txt_failed_official = "failed";
126 $percentage_failed = 0;
127 $failed_passed = 0;
128 $txt_passed_short = "passed";
129 $txt_passed_official = "passed";
130 $percentage_passed = 50;
131 $passed_passed = 1;
132
133 // Act
134 $this->ass_mark_schema->createSimpleSchema(
135 $txt_failed_short,
136 $txt_failed_official,
137 $percentage_failed,
138 $failed_passed,
139 $txt_passed_short,
140 $txt_passed_official,
141 $percentage_passed,
142 $passed_passed
143 );
144
145 $marks = $this->ass_mark_schema->mark_steps;
146
147 $failed = $marks[0];
148 $passed = $marks[1];
149
150 // Assert
151 $this->assertEquals(
152 $failed->getShortName(),
153 $txt_failed_short,
154 'Failed on $txt_failed_short'
155 );
156 $this->assertEquals(
157 $failed->getOfficialName(),
158 $txt_failed_official,
159 'Failed on $txt_failed_official'
160 );
161 $this->assertEquals(
162 $failed->getMinimumLevel(),
163 $percentage_failed,
164 'Failed on $percentage_failed'
165 );
166 $this->assertEquals(
167 $failed->getPassed(),
168 $failed_passed,
169 'Failed on $failed_passed'
170 );
171
172 $this->assertEquals(
173 $passed->getShortName(),
174 $txt_passed_short,
175 'Failed on $txt_passed_short'
176 );
177 $this->assertEquals(
178 $passed->getOfficialName(),
179 $txt_passed_official,
180 'Failed on $txt_passed_official'
181 );
182 $this->assertEquals(
183 $passed->getMinimumLevel(),
184 $percentage_passed,
185 'Failed on $percetage_passed'
186 );
187 $this->assertEquals(
188 $passed->getPassed(),
189 $passed_passed,
190 'Failed on $passed_passed'
191 );
192 }
193
197 public function testFlush()
198 {
199 // Arrange
200 $expected = is_array(array());
201 $this->ass_mark_schema->mark_steps = "a string";
202 $this->assertEquals($this->ass_mark_schema->mark_steps, "a string");
203 $this->ass_mark_schema->flush();
204
205 // Act
206 $actual = is_array($this->ass_mark_schema->mark_steps);
207
208 // Assert
209 $this->assertEquals(
210 $actual,
211 $expected,
212 "Method failed, mark_steps not an array."
213 );
214 }
215
219 public function testAddMarkStep()
220 {
221 // Arrange
222 $this->ass_mark_schema->flush();
223 $txt_short = "";
224 $txt_official = "";
225 $percentage = 0;
226 $passed = 0;
227
228 // Act
229 $this->ass_mark_schema->addMarkStep();
230 $mark_schema = $this->ass_mark_schema->mark_steps;
231 $mark_step = $mark_schema[0];
232
233 // Assert
234 $this->assertEquals(
235 $mark_step->getShortName(),
236 $txt_short,
237 'Failed on $txt_failed_short'
238 );
239 $this->assertEquals(
240 $mark_step->getOfficialName(),
241 $txt_official,
242 'Failed on $txt_failed_official'
243 );
244 $this->assertEquals(
245 $mark_step->getMinimumLevel(),
246 $percentage,
247 'Failed on $percentage_failed'
248 );
249 $this->assertEquals(
250 $mark_step->getPassed(),
251 $passed,
252 'Failed on $failed_passed'
253 );
254 }
255
256 public function testSaveToDb_regular()
257 {
258 /*
259 // Arrange
260 $ildb_stub = $this->createMock('ilDBInterface');
261
262 $ildb_stub->expects($this->any())
263 ->method('query')
264 ->will($this->returnValue('foo'));
265
266 $ildb_stub->expects($this->any())
267 ->method('numRows')
268 ->will($this->returnValue(1));
269
270 $db_result_1 = array('cmi_node_id' => 8);
271 $db_result_2 = array('cmi_node_id' => 10);
272 $db_result_3 = array('cmi_node_id' => 12);
273 $db_result_4 = array('cmi_node_id' => 14);
274
275 $ildb_stub->expects($this->any())
276 ->method('fetchAssoc')
277 ->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
278 */
279 }
280}
$failed
Definition: Utf8Test.php:85
A class defining mark schemas for assessment test objects.
An exception for terminatinating execution or to throw for unit testing.
Unit tests for single choice questions.
testCreateSimpleSchemaDefaults()
Test for createSimpleSchema using defaults.
testCreateSimpleSchemaCustom()
Test for createSimpleSchema using custom values.
testFlush()
Test for flush()
testAddMarkStep()
Test for addMarkStep()
testConstructor()
Test constructor.