ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
21 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
22 ilUnitUtil::performInitialisation();
23 }
24 else
25 {
26 chdir( dirname( __FILE__ ) );
27 chdir('../../../');
28 }
29 // Arrange
30 include_once './Modules/Test/classes/class.assMarkSchema.php';
31 $this->ass_mark_schema = new ASS_MarkSchema();
32 }
33
37 public function testConstructor()
38 {
39 // Arrange
40 $expected = is_array(array());
41
42 // Act
43 $actual = is_array($this->ass_mark_schema->mark_steps);
44
45 // Assert
46 $this->assertEquals(
47 $actual,
48 $expected,
49 "Constructor failed, mark_steps not an array."
50 );
51
52 }
53
58 {
59 // Arrange
60
61
62 $txt_failed_short = "failed";
63 $txt_failed_official = "failed";
64 $percentage_failed = 0;
65 $failed_passed = 0;
66 $txt_passed_short = "passed";
67 $txt_passed_official = "passed";
68 $percentage_passed = 50;
69 $passed_passed = 1;
70
71 // Act
72 $this->ass_mark_schema->createSimpleSchema();
73 $marks = $this->ass_mark_schema->mark_steps;
74
75 $failed = $marks[0];
76 $passed = $marks[1];
77
78 // Assert
79 $this->assertEquals(
80 $failed->getShortName(),
81 $txt_failed_short,
82 'Failed on $txt_failed_short'
83 );
84 $this->assertEquals(
85 $failed->getOfficialName(),
86 $txt_failed_official,
87 'Failed on $txt_failed_official'
88 );
89 $this->assertEquals(
90 $failed->getMinimumLevel(),
91 $percentage_failed,
92 'Failed on $percentage_failed'
93 );
94 $this->assertEquals(
95 $failed->getPassed(),
96 $failed_passed,
97 'Failed on $failed_passed'
98 );
99
100 $this->assertEquals(
101 $passed->getShortName(),
102 $txt_passed_short,
103 'Failed on $txt_passed_short'
104 );
105 $this->assertEquals(
106 $passed->getOfficialName(),
107 $txt_passed_official,
108 'Failed on $txt_passed_official'
109 );
110 $this->assertEquals(
111 $passed->getMinimumLevel(),
112 $percentage_passed,
113 'Failed on $percetage_passed'
114 );
115 $this->assertEquals(
116 $passed->getPassed(),
117 $passed_passed,
118 'Failed on $passed_passed'
119 );
120
121 }
122
127 {
128 // Arrange
129 $txt_failed_short = "failed";
130 $txt_failed_official = "failed";
131 $percentage_failed = 0;
132 $failed_passed = 0;
133 $txt_passed_short = "passed";
134 $txt_passed_official = "passed";
135 $percentage_passed = 50;
136 $passed_passed = 1;
137
138 // Act
139 $this->ass_mark_schema->createSimpleSchema(
140 $txt_failed_short,
141 $txt_failed_official,
142 $percentage_failed,
143 $failed_passed,
144 $txt_passed_short,
145 $txt_passed_official,
146 $percentage_passed,
147 $passed_passed
148 );
149
150 $marks = $this->ass_mark_schema->mark_steps;
151
152 $failed = $marks[0];
153 $passed = $marks[1];
154
155 // Assert
156 $this->assertEquals(
157 $failed->getShortName(),
158 $txt_failed_short,
159 'Failed on $txt_failed_short'
160 );
161 $this->assertEquals(
162 $failed->getOfficialName(),
163 $txt_failed_official,
164 'Failed on $txt_failed_official'
165 );
166 $this->assertEquals(
167 $failed->getMinimumLevel(),
168 $percentage_failed,
169 'Failed on $percentage_failed'
170 );
171 $this->assertEquals(
172 $failed->getPassed(),
173 $failed_passed,
174 'Failed on $failed_passed'
175 );
176
177 $this->assertEquals(
178 $passed->getShortName(),
179 $txt_passed_short,
180 'Failed on $txt_passed_short'
181 );
182 $this->assertEquals(
183 $passed->getOfficialName(),
184 $txt_passed_official,
185 'Failed on $txt_passed_official'
186 );
187 $this->assertEquals(
188 $passed->getMinimumLevel(),
189 $percentage_passed,
190 'Failed on $percetage_passed'
191 );
192 $this->assertEquals(
193 $passed->getPassed(),
194 $passed_passed,
195 'Failed on $passed_passed'
196 );
197 }
198
202 public function testFlush()
203 {
204 // Arrange
205 $expected = is_array(array());
206 $this->ass_mark_schema->mark_steps = "a string";
207 $this->assertEquals($this->ass_mark_schema->mark_steps, "a string");
208 $this->ass_mark_schema->flush();
209
210 // Act
211 $actual = is_array($this->ass_mark_schema->mark_steps);
212
213 // Assert
214 $this->assertEquals(
215 $actual,
216 $expected,
217 "Method failed, mark_steps not an array."
218 );
219
220 }
221
225 public function testAddMarkStep()
226 {
227 // Arrange
228 $this->ass_mark_schema->flush();
229 $txt_short = "";
230 $txt_official = "";
231 $percentage = 0;
232 $passed = 0;
233
234 // Act
235 $this->ass_mark_schema->addMarkStep();
236 $mark_schema = $this->ass_mark_schema->mark_steps;
237 $mark_step = $mark_schema[0];
238
239 // Assert
240 $this->assertEquals(
241 $mark_step->getShortName(),
242 $txt_short,
243 'Failed on $txt_failed_short'
244 );
245 $this->assertEquals(
246 $mark_step->getOfficialName(),
247 $txt_official,
248 'Failed on $txt_failed_official'
249 );
250 $this->assertEquals(
251 $mark_step->getMinimumLevel(),
252 $percentage,
253 'Failed on $percentage_failed'
254 );
255 $this->assertEquals(
256 $mark_step->getPassed(),
257 $passed,
258 'Failed on $failed_passed'
259 );
260 }
261
263 {
264 /*
265 // Arrange
266 require_once 'Services/Database/classes/class.ilDB.php';
267 $ildb_stub = $this->getMock('ilDB');
268
269 $ildb_stub->expects($this->any())
270 ->method('query')
271 ->will($this->returnValue('foo'));
272
273 $ildb_stub->expects($this->any())
274 ->method('numRows')
275 ->will($this->returnValue(1));
276
277 $db_result_1 = array('cmi_node_id' => 8);
278 $db_result_2 = array('cmi_node_id' => 10);
279 $db_result_3 = array('cmi_node_id' => 12);
280 $db_result_4 = array('cmi_node_id' => 14);
281
282 $ildb_stub->expects($this->any())
283 ->method('fetchAssoc')
284 ->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
285 */
286 }
287}
$failed
Definition: Utf8Test.php:86
A class defining mark schemas for assessment test objects.
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.