ILIAS  release_8 Revision v8.23
ilassMarkSchemaTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for ilassMarkSchemaTest:
+ Collaboration diagram for ilassMarkSchemaTest:

Public Member Functions

 testConstructor ()
 Test constructor. More...
 
 testCreateSimpleSchemaDefaults ()
 Test for createSimpleSchema using defaults. More...
 
 testCreateSimpleSchemaCustom ()
 Test for createSimpleSchema using custom values. More...
 
 testFlush ()
 Test for flush() More...
 
 testAddMarkStep ()
 Test for addMarkStep() More...
 
 testSaveToDb_regular ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Private Attributes

ASS_MarkSchema $ass_mark_schema
 

Detailed Description

Unit tests for single choice questions.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 27 of file ilassMarkSchemaTest.php.

Member Function Documentation

◆ setUp()

ilassMarkSchemaTest::setUp ( )
protected

Definition at line 32 of file ilassMarkSchemaTest.php.

32  : void
33  {
34  chdir(dirname(__FILE__));
35  chdir('../../../');
36 
37  // Arrange
38  include_once './Modules/Test/classes/class.assMarkSchema.php';
39  $this->ass_mark_schema = new ASS_MarkSchema();
40  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testAddMarkStep()

ilassMarkSchemaTest::testAddMarkStep ( )

Test for addMarkStep()

Definition at line 229 of file ilassMarkSchemaTest.php.

230  {
231  // Arrange
232  $this->ass_mark_schema->flush();
233  $txt_short = "";
234  $txt_official = "";
235  $percentage = 0;
236  $passed = 0;
237 
238  // Act
239  $this->ass_mark_schema->addMarkStep();
240  $mark_schema = $this->ass_mark_schema->mark_steps;
241  $mark_step = $mark_schema[0];
242 
243  // Assert
244  $this->assertEquals(
245  $mark_step->getShortName(),
246  $txt_short,
247  'Failed on $txt_failed_short'
248  );
249  $this->assertEquals(
250  $mark_step->getOfficialName(),
251  $txt_official,
252  'Failed on $txt_failed_official'
253  );
254  $this->assertEquals(
255  $mark_step->getMinimumLevel(),
256  $percentage,
257  'Failed on $percentage_failed'
258  );
259  $this->assertEquals(
260  $mark_step->getPassed(),
261  $passed,
262  'Failed on $failed_passed'
263  );
264  }

◆ testConstructor()

ilassMarkSchemaTest::testConstructor ( )

Test constructor.

Definition at line 45 of file ilassMarkSchemaTest.php.

46  {
47  // Arrange
48  $expected = is_array(array());
49 
50  // Act
51  $actual = is_array($this->ass_mark_schema->mark_steps);
52 
53  // Assert
54  $this->assertEquals(
55  $actual,
56  $expected,
57  "Constructor failed, mark_steps not an array."
58  );
59  }

◆ testCreateSimpleSchemaCustom()

ilassMarkSchemaTest::testCreateSimpleSchemaCustom ( )

Test for createSimpleSchema using custom values.

Definition at line 131 of file ilassMarkSchemaTest.php.

132  {
133  // Arrange
134  $txt_failed_short = "failed";
135  $txt_failed_official = "failed";
136  $percentage_failed = 0;
137  $failed_passed = 0;
138  $txt_passed_short = "passed";
139  $txt_passed_official = "passed";
140  $percentage_passed = 50;
141  $passed_passed = 1;
142 
143  // Act
144  $this->ass_mark_schema->createSimpleSchema(
145  $txt_failed_short,
146  $txt_failed_official,
147  $percentage_failed,
148  $failed_passed,
149  $txt_passed_short,
150  $txt_passed_official,
151  $percentage_passed,
152  $passed_passed
153  );
154 
155  $marks = $this->ass_mark_schema->mark_steps;
156 
157  $failed = $marks[0];
158  $passed = $marks[1];
159 
160  // Assert
161  $this->assertEquals(
162  $failed->getShortName(),
163  $txt_failed_short,
164  'Failed on $txt_failed_short'
165  );
166  $this->assertEquals(
167  $failed->getOfficialName(),
168  $txt_failed_official,
169  'Failed on $txt_failed_official'
170  );
171  $this->assertEquals(
172  $failed->getMinimumLevel(),
173  $percentage_failed,
174  'Failed on $percentage_failed'
175  );
176  $this->assertEquals(
177  $failed->getPassed(),
178  $failed_passed,
179  'Failed on $failed_passed'
180  );
181 
182  $this->assertEquals(
183  $passed->getShortName(),
184  $txt_passed_short,
185  'Failed on $txt_passed_short'
186  );
187  $this->assertEquals(
188  $passed->getOfficialName(),
189  $txt_passed_official,
190  'Failed on $txt_passed_official'
191  );
192  $this->assertEquals(
193  $passed->getMinimumLevel(),
194  $percentage_passed,
195  'Failed on $percetage_passed'
196  );
197  $this->assertEquals(
198  $passed->getPassed(),
199  $passed_passed,
200  'Failed on $passed_passed'
201  );
202  }

◆ testCreateSimpleSchemaDefaults()

ilassMarkSchemaTest::testCreateSimpleSchemaDefaults ( )

Test for createSimpleSchema using defaults.

Definition at line 64 of file ilassMarkSchemaTest.php.

65  {
66  // Arrange
67 
68  $txt_failed_short = "failed";
69  $txt_failed_official = "failed";
70  $percentage_failed = 0;
71  $failed_passed = 0;
72  $txt_passed_short = "passed";
73  $txt_passed_official = "passed";
74  $percentage_passed = 50;
75  $passed_passed = 1;
76 
77  // Act
78  $this->ass_mark_schema->createSimpleSchema();
79  $marks = $this->ass_mark_schema->mark_steps;
80 
81  $failed = $marks[0];
82  $passed = $marks[1];
83 
84  // Assert
85  $this->assertEquals(
86  $failed->getShortName(),
87  $txt_failed_short,
88  'Failed on $txt_failed_short'
89  );
90  $this->assertEquals(
91  $failed->getOfficialName(),
92  $txt_failed_official,
93  'Failed on $txt_failed_official'
94  );
95  $this->assertEquals(
96  $failed->getMinimumLevel(),
97  $percentage_failed,
98  'Failed on $percentage_failed'
99  );
100  $this->assertEquals(
101  $failed->getPassed(),
102  $failed_passed,
103  'Failed on $failed_passed'
104  );
105 
106  $this->assertEquals(
107  $passed->getShortName(),
108  $txt_passed_short,
109  'Failed on $txt_passed_short'
110  );
111  $this->assertEquals(
112  $passed->getOfficialName(),
113  $txt_passed_official,
114  'Failed on $txt_passed_official'
115  );
116  $this->assertEquals(
117  $passed->getMinimumLevel(),
118  $percentage_passed,
119  'Failed on $percetage_passed'
120  );
121  $this->assertEquals(
122  $passed->getPassed(),
123  $passed_passed,
124  'Failed on $passed_passed'
125  );
126  }

◆ testFlush()

ilassMarkSchemaTest::testFlush ( )

Test for flush()

Definition at line 207 of file ilassMarkSchemaTest.php.

208  {
209  // Arrange
210  $expected = is_array(array());
211  $this->ass_mark_schema->mark_steps = array("a string");
212  $this->assertEquals(array("a string"), $this->ass_mark_schema->mark_steps);
213  $this->ass_mark_schema->flush();
214 
215  // Act
216  $actual = is_array($this->ass_mark_schema->mark_steps);
217 
218  // Assert
219  $this->assertEquals(
220  $actual,
221  $expected,
222  "Method failed, mark_steps not an array."
223  );
224  }

◆ testSaveToDb_regular()

ilassMarkSchemaTest::testSaveToDb_regular ( )

Definition at line 269 of file ilassMarkSchemaTest.php.

270  {
271  /*
272  // Arrange
273  $ildb_stub = $this->createMock('ilDBInterface');
274 
275  $ildb_stub->expects($this->any())
276  ->method('query')
277  ->will($this->returnValue('foo'));
278 
279  $ildb_stub->expects($this->any())
280  ->method('numRows')
281  ->will($this->returnValue(1));
282 
283  $db_result_1 = array('cmi_node_id' => 8);
284  $db_result_2 = array('cmi_node_id' => 10);
285  $db_result_3 = array('cmi_node_id' => 12);
286  $db_result_4 = array('cmi_node_id' => 14);
287 
288  $ildb_stub->expects($this->any())
289  ->method('fetchAssoc')
290  ->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
291  */
292  }

Field Documentation

◆ $ass_mark_schema

ASS_MarkSchema ilassMarkSchemaTest::$ass_mark_schema
private

Definition at line 29 of file ilassMarkSchemaTest.php.

◆ $backupGlobals

ilassMarkSchemaTest::$backupGlobals = false
protected

Definition at line 30 of file ilassMarkSchemaTest.php.


The documentation for this class was generated from the following file: