ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 

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 13 of file ilassMarkSchemaTest.php.

Member Function Documentation

◆ setUp()

ilassMarkSchemaTest::setUp ( )
protected

Definition at line 17 of file ilassMarkSchemaTest.php.

References defined.

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  }
A class defining mark schemas for assessment test objects.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ testAddMarkStep()

ilassMarkSchemaTest::testAddMarkStep ( )

Test for addMarkStep()

Definition at line 225 of file ilassMarkSchemaTest.php.

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  }

◆ testConstructor()

ilassMarkSchemaTest::testConstructor ( )

Test constructor.

Definition at line 37 of file ilassMarkSchemaTest.php.

References array.

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  }
Create styles array
The data for the language used.

◆ testCreateSimpleSchemaCustom()

ilassMarkSchemaTest::testCreateSimpleSchemaCustom ( )

Test for createSimpleSchema using custom values.

Definition at line 126 of file ilassMarkSchemaTest.php.

References $failed.

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  }
$failed
Definition: Utf8Test.php:85

◆ testCreateSimpleSchemaDefaults()

ilassMarkSchemaTest::testCreateSimpleSchemaDefaults ( )

Test for createSimpleSchema using defaults.

Definition at line 57 of file ilassMarkSchemaTest.php.

References $failed.

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  }
$failed
Definition: Utf8Test.php:85

◆ testFlush()

ilassMarkSchemaTest::testFlush ( )

Test for flush()

Definition at line 202 of file ilassMarkSchemaTest.php.

References array.

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  }
Create styles array
The data for the language used.

◆ testSaveToDb_regular()

ilassMarkSchemaTest::testSaveToDb_regular ( )

Definition at line 262 of file ilassMarkSchemaTest.php.

263  {
264  /*
265  // Arrange
266  $ildb_stub = $this->getMock('ilDBInterface');
267 
268  $ildb_stub->expects($this->any())
269  ->method('query')
270  ->will($this->returnValue('foo'));
271 
272  $ildb_stub->expects($this->any())
273  ->method('numRows')
274  ->will($this->returnValue(1));
275 
276  $db_result_1 = array('cmi_node_id' => 8);
277  $db_result_2 = array('cmi_node_id' => 10);
278  $db_result_3 = array('cmi_node_id' => 12);
279  $db_result_4 = array('cmi_node_id' => 14);
280 
281  $ildb_stub->expects($this->any())
282  ->method('fetchAssoc')
283  ->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
284  */
285  }

Field Documentation

◆ $backupGlobals

ilassMarkSchemaTest::$backupGlobals = FALSE
protected

Definition at line 15 of file ilassMarkSchemaTest.php.


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