ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assClozeGapTest Class Reference

Unit tests. More...

+ Inheritance diagram for assClozeGapTest:
+ Collaboration diagram for assClozeGapTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_setGetType_shouldReturnUnchangedValue ()
 
 test_setType_shouldSetDefaultIfNotPassed ()
 
 test_setGetShuffle_shouldReturnUnchangedValue ()
 
 test_arrayShuffle_shouldNotReturnArrayUnshuffled ()
 
 test_addGetItem_shouldReturnValueUnchanged ()
 
 test_addGetItem_shouldReturnValueUnchangedMultiple ()
 
 test_getItem_shouldReturnNullIfNoItemAtGivenIndex ()
 
 test_addGetItem_shouldReturnValueUnchangedMultiplePlus ()
 
 test_getItems_shouldReturnItemsAdded ()
 
 test_getItemsWithShuffle_shouldReturnItemsAddedShuffled ()
 
 test_getItemsRaw_shouldReturnItemsAdded ()
 
 test_getItemCount_shouldReturnCorrectCount ()
 
 test_deleteItem_shouldDeleteGivenItem ()
 
 test_clearItems_shouldClearItems ()
 
 test_setItemLowerBound_shouldSetItemsLowerBound ()
 
 test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh ()
 
 test_setItemUpperBound_shouldSetItemsUpperBound ()
 
 test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow ()
 
 test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext ()
 
 test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes ()
 
 test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText ()
 
 test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti ()
 
 test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric ()
 
 test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests.

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

Definition at line 11 of file assClozeGapTest.php.

Member Function Documentation

◆ setUp()

assClozeGapTest::setUp ( )
protected

Definition at line 15 of file assClozeGapTest.php.

References assBaseTestCase\setGlobalVariable().

16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19  ilUnitUtil::performInitialisation();
20  } else {
21  chdir(dirname(__FILE__));
22  chdir('../../../');
23  }
24 
25  parent::setUp();
26 
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  require_once './Services/Randomization/classes/class.ilArrayElementShuffler.php';
29  $util_mock = $this->createMock('ilUtil', array('stripSlashes'), array(), '', false);
30  $util_mock->expects($this->any())->method('stripSlashes')->will($this->returnArgument(0));
31  $this->setGlobalVariable('ilUtils', $util_mock);
32  }
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ test_addGetItem_shouldReturnValueUnchanged()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchanged ( )

Definition at line 109 of file assClozeGapTest.php.

110  {
111  // Arrange
112  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
113  $instance = new assClozeGap(0); // 0 - text gap
114  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
115  $expected = new assAnswerCloze('Esther', 1.0, 0);
116 
117  // Act
118  $instance->addItem($expected);
119  $actual = $instance->getItem(0);
120 
121  // Assert
122  $this->assertEquals($expected, $actual);
123  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_addGetItem_shouldReturnValueUnchangedMultiple()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiple ( )

Definition at line 125 of file assClozeGapTest.php.

126  {
127  // Arrange
128  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
129  $instance = new assClozeGap(0); // 0 - text gap
130  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
131  $answer = new assAnswerCloze('Bert', 1.0, 0);
132  $expected = new assAnswerCloze('Esther', 1.0, 0);
133 
134  // Act
135  $instance->addItem($answer);
136  $instance->addItem($expected);
137  $actual = $instance->getItem(0);
138 
139  // Assert
140  $this->assertEquals($expected, $actual);
141  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_addGetItem_shouldReturnValueUnchangedMultiplePlus()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiplePlus ( )

Definition at line 164 of file assClozeGapTest.php.

165  {
166  // Arrange
167  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
168  $instance = new assClozeGap(0); // 0 - text gap
169 
170  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
171  $answer = new assAnswerCloze('Bert', 1.0, 1);
172  $answer2 = new assAnswerCloze('Fred', 1.0, 2);
173  $answer3 = new assAnswerCloze('Karl', 1.0, 3);
174  $expected = new assAnswerCloze('Esther', 1.0, 0);
175 
176  // Act
177  $instance->addItem($answer);
178  $instance->addItem($answer2);
179  $instance->addItem($answer3);
180  $instance->addItem($expected);
181  $actual = $instance->getItem(0);
182 
183  // Assert
184  $this->assertEquals($expected, $actual);
185  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_arrayShuffle_shouldNotReturnArrayUnshuffled()

assClozeGapTest::test_arrayShuffle_shouldNotReturnArrayUnshuffled ( )

Definition at line 90 of file assClozeGapTest.php.

91  {
92  // Arrange
93  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
94 
95  $instance = new assClozeGap(0); // 0 - text gap
96 
97  // Act
98  $the_unexpected = array('Killing', 'Kunkel', 'Luetzenkirchen',
99  'Meyer', 'Jansen', 'Heyser', 'Becker');
100  $instance->items = $the_unexpected;
101  $instance->setShuffle(true);
102 
103  $actual = $instance->getItems(new ilArrayElementShuffler);
104 
105  // Assert
106  $this->assertNotEquals($the_unexpected, $actual);
107  }
Class for cloze question gaps.

◆ test_clearItems_shouldClearItems()

assClozeGapTest::test_clearItems_shouldClearItems ( )

Definition at line 340 of file assClozeGapTest.php.

341  {
342  // Arrange
343  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
344  $instance = new assClozeGap(0); // 0 - text gap
345  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
346  $item1 = new assAnswerCloze('Bert', 1.0, 0);
347  $item2 = new assAnswerCloze('Fred', 1.0, 2);
348  $item3 = new assAnswerCloze('Karl', 1.0, 1);
349  $item4 = new assAnswerCloze('Esther', 1.0, 3);
350 
351  $instance->addItem($item1);
352  $instance->addItem($item2);
353  $instance->addItem($item3);
354  $instance->addItem($item4);
355 
356  $expected = 0;
357 
358  // Act
359  $instance->clearItems();
360  $actual = $instance->getItemCount();
361 
362  // Assert
363  $this->assertEquals($expected, $actual);
364  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_deleteItem_shouldDeleteGivenItem()

assClozeGapTest::test_deleteItem_shouldDeleteGivenItem ( )

Definition at line 317 of file assClozeGapTest.php.

318  {
319  // Arrange
320  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
321  $instance = new assClozeGap(0); // 0 - text gap
322  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
323  $item1 = new assAnswerCloze('Bert', 1.0, 0);
324  $item2 = new assAnswerCloze('Fred', 1.0, 1);
325 
326  $instance->addItem($item1);
327  $instance->addItem($item2);
328 
329  $expected = array('1' => $item2);
330 
331  // Act
332  $instance->deleteItem(0);
333 
334  $actual = $instance->getItemsRaw();
335 
336  // Assert
337  $this->assertEquals($expected, $actual);
338  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes()

assClozeGapTest::test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes ( )

Definition at line 477 of file assClozeGapTest.php.

478  {
479  // Arrange
480  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
481  $instance = new assClozeGap(0); // 0 - text gap
482  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
483  $item1 = new assAnswerCloze('Bert', 1.0, 0);
484  $item2 = new assAnswerCloze('Fred', 2.0, 2);
485  $item3 = new assAnswerCloze('Karl', 3.0, 1);
486  $item4 = new assAnswerCloze('Esther', 4.0, 3);
487 
488  $instance->addItem($item1);
489  $instance->addItem($item2);
490  $instance->addItem($item3);
491  $instance->addItem($item4);
492 
493  $expected = array( 0 => 3 );
494 
495  // Act
496  $actual = $instance->getBestSolutionIndexes();
497 
498  // Assert
499  $this->assertEquals($expected, $actual);
500  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric ( )

Definition at line 572 of file assClozeGapTest.php.

References $DIC, and $GLOBALS.

573  {
574  // Arrange
575  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
576  $instance = new assClozeGap(2); // 0 - text gap
577  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
578  $item1 = new assAnswerCloze(10, 1.0, 0);
579  $item2 = new assAnswerCloze(20, 2.0, 2);
580  $item3 = new assAnswerCloze(30, 3.0, 1);
581  $item4 = new assAnswerCloze(100, 4.0, 3);
582 
583  // We need the $lng-mock.
584  require_once './Services/Language/classes/class.ilLanguage.php';
585  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
586  $lng_mock->expects($this->any())->method('txt')->will($this->returnValue('Test'));
587  global $DIC;
588  unset($DIC['lng']);
589  $DIC['lng'] = $lng_mock;
590  $GLOBALS['lng'] = $DIC['lng'];
591 
592  $instance->addItem($item1);
593  $instance->addItem($item2);
594  $instance->addItem($item3);
595  $instance->addItem($item4);
596 
597  $expected = 100;
598 
599  // Act
600  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
601 
602  // Assert
603  $this->assertEquals($expected, $actual);
604  }
Class for cloze question numeric answers.
global $DIC
Definition: saml.php:7
Class for cloze question gaps.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText ( )

Definition at line 502 of file assClozeGapTest.php.

References $DIC, and $GLOBALS.

503  {
504  // Arrange
505  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
506  $instance = new assClozeGap(0); // 0 - text gap
507  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
508  $item1 = new assAnswerCloze('Bert', 1.0, 0);
509  $item2 = new assAnswerCloze('Fred', 2.0, 2);
510  $item3 = new assAnswerCloze('Karl', 3.0, 1);
511  $item4 = new assAnswerCloze('Esther', 4.0, 3);
512 
513  // We need the $lng-mock.
514  require_once './Services/Language/classes/class.ilLanguage.php';
515  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
516  $lng_mock->expects($this->any())->method('txt')->will($this->returnValue('Test'));
517  global $DIC;
518  unset($DIC['lng']);
519  $DIC['lng'] = $lng_mock;
520  $GLOBALS['lng'] = $DIC['lng'];
521 
522  $instance->addItem($item1);
523  $instance->addItem($item2);
524  $instance->addItem($item3);
525  $instance->addItem($item4);
526 
527  $expected = 'Esther';
528 
529  // Act
530  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
531 
532  // Assert
533  $this->assertEquals($expected, $actual);
534  }
Class for cloze question numeric answers.
global $DIC
Definition: saml.php:7
Class for cloze question gaps.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti ( )

Definition at line 536 of file assClozeGapTest.php.

References $DIC, and $GLOBALS.

537  {
538  // Arrange
539  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
540  $instance = new assClozeGap(0); // 0 - text gap
541  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
542  $item1 = new assAnswerCloze('Bert', 1.0, 0);
543  $item2 = new assAnswerCloze('Fred', 2.0, 2);
544  $item3 = new assAnswerCloze('Karl', 4, 1);
545  $item4 = new assAnswerCloze('Esther', 4, 3);
546 
547  // We need the $lng-mock.
548  require_once './Services/Language/classes/class.ilLanguage.php';
549  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
550  $lng_mock->expects($this->any())->method('txt')->will($this->returnValue('or'));
551  global $DIC;
552  unset($DIC['lng']);
553  $DIC['lng'] = $lng_mock;
554  $GLOBALS['lng'] = $DIC['lng'];
555 
556  $instance->setShuffle(true);
557  $instance->addItem($item1);
558  $instance->addItem($item2);
559  $instance->addItem($item3);
560  $instance->addItem($item4);
561 
562  $expected1 = 'Karl or Esther';
563  $expected2 = 'Esther or Karl';
564 
565  // Act
566  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
567 
568  // Assert
569  $this->assertTrue(($actual == $expected1) || ($actual == $expected2));
570  }
Class for cloze question numeric answers.
global $DIC
Definition: saml.php:7
Class for cloze question gaps.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK ( )

Definition at line 606 of file assClozeGapTest.php.

References $DIC, and $GLOBALS.

607  {
608  // Arrange
609  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
610  $instance = new assClozeGap(11); // 0 - text gap
611  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
612  $item1 = new assAnswerCloze(10, 1.0, 0);
613  $item2 = new assAnswerCloze(20, 2.0, 2);
614  $item3 = new assAnswerCloze(30, 3.0, 1);
615  $item4 = new assAnswerCloze(100, 4.0, 3);
616 
617  // We need the $lng-mock.
618  require_once './Services/Language/classes/class.ilLanguage.php';
619  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
620  $lng_mock->expects($this->any())->method('txt')->will($this->returnValue('Test'));
621  global $DIC;
622  unset($DIC['lng']);
623  $DIC['lng'] = $lng_mock;
624  $GLOBALS['lng'] = $DIC['lng'];
625 
626  $instance->addItem($item1);
627  $instance->addItem($item2);
628  $instance->addItem($item3);
629  $instance->addItem($item4);
630 
631  $expected = '';
632 
633  // Act
634  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
635 
636  // Assert
637  $this->assertEquals($expected, $actual);
638  }
Class for cloze question numeric answers.
global $DIC
Definition: saml.php:7
Class for cloze question gaps.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ test_getItem_shouldReturnNullIfNoItemAtGivenIndex()

assClozeGapTest::test_getItem_shouldReturnNullIfNoItemAtGivenIndex ( )

Definition at line 143 of file assClozeGapTest.php.

144  {
145  // Arrange
146  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
147  $instance = new assClozeGap(0); // 0 - text gap
148  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
149  $answer1 = new assAnswerCloze('Bert', 1.0, 0);
150  $answer2 = new assAnswerCloze('Esther', 1.0, 1);
151 
152  $instance->addItem($answer1);
153  $instance->addItem($answer2);
154 
155  $expected = null;
156 
157  // Act
158  $actual = $instance->getItem(2);
159 
160  // Assert
161  $this->assertEquals($expected, $actual);
162  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getItemCount_shouldReturnCorrectCount()

assClozeGapTest::test_getItemCount_shouldReturnCorrectCount ( )

Definition at line 274 of file assClozeGapTest.php.

275  {
276  // Arrange
277  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
278  $instance = new assClozeGap(0); // 0 - text gap
279  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
280  $item1 = new assAnswerCloze('Bert', 1.0, 0);
281  $item2 = new assAnswerCloze('Fred', 1.0, 2);
282  $item3 = new assAnswerCloze('Karl', 1.0, 1);
283  $item4 = new assAnswerCloze('Esther', 1.0, 3);
284  $expected = 4;
285 
286  // Act
287  $instance->addItem($item1);
288  $instance->addItem($item2);
289  $instance->addItem($item3);
290  $instance->addItem($item4);
291  $actual = $instance->getItemCount();
292 
293  // Assert
294  $this->assertEquals($expected, $actual);
295  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getItems_shouldReturnItemsAdded()

assClozeGapTest::test_getItems_shouldReturnItemsAdded ( )

Definition at line 187 of file assClozeGapTest.php.

188  {
189  // Arrange
190  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
191  $instance = new assClozeGap(0); // 0 - text gap
192  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
193  $item1 = new assAnswerCloze('Bert', 1.0, 0);
194  $item2 = new assAnswerCloze('Fred', 1.0, 1);
195  $item3 = new assAnswerCloze('Karl', 1.0, 2);
196  $item4 = new assAnswerCloze('Esther', 1.0, 3);
197  $instance->setShuffle(false);
198  $expected = array($item1, $item2, $item3, $item4);
199  // Act
200  $instance->addItem($item1);
201  $instance->addItem($item2);
202  $instance->addItem($item3);
203  $instance->addItem($item4);
204  $actual = $instance->getItems(new ilArrayElementShuffler);
205 
206  // Assert
207  $this->assertEquals($expected, $actual);
208  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getItemsRaw_shouldReturnItemsAdded()

assClozeGapTest::test_getItemsRaw_shouldReturnItemsAdded ( )

Definition at line 251 of file assClozeGapTest.php.

252  {
253  // Arrange
254  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
255  $instance = new assClozeGap(0); // 0 - text gap
256  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
257  $item1 = new assAnswerCloze('Bert', 1.0, 0);
258  $item2 = new assAnswerCloze('Fred', 1.0, 1);
259  $item3 = new assAnswerCloze('Karl', 1.0, 2);
260  $item4 = new assAnswerCloze('Esther', 1.0, 3);
261  $expected = array($item1, $item2, $item3, $item4);
262 
263  // Act
264  $instance->addItem($item1);
265  $instance->addItem($item2);
266  $instance->addItem($item3);
267  $instance->addItem($item4);
268  $actual = $instance->getItemsRaw();
269 
270  // Assert
271  $this->assertEquals($expected, $actual);
272  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getItemsWithShuffle_shouldReturnItemsAddedShuffled()

assClozeGapTest::test_getItemsWithShuffle_shouldReturnItemsAddedShuffled ( )

Definition at line 210 of file assClozeGapTest.php.

211  {
212  // Arrange
213  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
214  $instance = new assClozeGap(0); // 0 - text gap
215  $instance->setShuffle(true);
216  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
217  $item1 = new assAnswerCloze('Bert', 1.0, 0);
218  $item2 = new assAnswerCloze('Fred', 1.0, 1);
219  $item3 = new assAnswerCloze('Karl', 1.0, 2);
220  $item4 = new assAnswerCloze('Esther', 1.0, 3);
221  $item5 = new assAnswerCloze('Herbert', 1.0, 4);
222  $item6 = new assAnswerCloze('Karina', 1.0, 5);
223  $item7 = new assAnswerCloze('Helmut', 1.0, 6);
224  $item8 = new assAnswerCloze('Kerstin', 1.0, 7);
225  $expected = array($item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8);
226 
227  // Act
228  $instance->addItem($item1);
229  $instance->addItem($item2);
230  $instance->addItem($item3);
231  $instance->addItem($item4);
232  $instance->addItem($item5);
233  $instance->addItem($item6);
234  $instance->addItem($item7);
235  $instance->addItem($item8);
236  $actual = $instance->getItems(new ilArrayElementShuffler);
237 
238  // Assert
239  $this->assertTrue(is_array($actual));
240  $this->assertTrue(in_array($item1, $actual));
241  $this->assertTrue(in_array($item2, $actual));
242  $this->assertTrue(in_array($item3, $actual));
243  $this->assertTrue(in_array($item4, $actual));
244  $this->assertTrue(in_array($item5, $actual));
245  $this->assertTrue(in_array($item6, $actual));
246  $this->assertTrue(in_array($item7, $actual));
247  $this->assertTrue(in_array($item8, $actual));
248  $this->assertNotEquals($expected, $actual);
249  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext()

assClozeGapTest::test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext ( )

Definition at line 452 of file assClozeGapTest.php.

453  {
454  // Arrange
455  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
456  $instance = new assClozeGap(0); // 0 - text gap
457  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
458  $item1 = new assAnswerCloze('Bert', 1.0, 0);
459  $item2 = new assAnswerCloze('Fred', 1.0, 2);
460  $item3 = new assAnswerCloze('Karl', 1.0, 1);
461  $item4 = new assAnswerCloze('Esther', 1.0, 3);
462 
463  $instance->addItem($item1);
464  $instance->addItem($item2);
465  $instance->addItem($item3);
466  $instance->addItem($item4);
467 
468  $expected = strlen($item4->getAnswertext());
469 
470  // Act
471  $actual = $instance->getMaxWidth();
472 
473  // Assert
474  $this->assertEquals($expected, $actual);
475  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_instantiateObject_shouldReturnInstance()

assClozeGapTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 34 of file assClozeGapTest.php.

35  {
36  // Arrange
37  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
38 
39  // Act
40  $instance = new assClozeGap(0); // 0 - text gap
41 
42  $this->assertInstanceOf('assClozeGap', $instance);
43  }
Class for cloze question gaps.

◆ test_setGetShuffle_shouldReturnUnchangedValue()

assClozeGapTest::test_setGetShuffle_shouldReturnUnchangedValue ( )

Definition at line 75 of file assClozeGapTest.php.

76  {
77  // Arrange
78  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
79  $instance = new assClozeGap(0); // 0 - text gap
80  $expected = true;
81 
82  // Act
83  $instance->setShuffle($expected);
84  $actual = $instance->getShuffle();
85 
86  // Assert
87  $this->assertEquals($expected, $actual);
88  }
Class for cloze question gaps.

◆ test_setGetType_shouldReturnUnchangedValue()

assClozeGapTest::test_setGetType_shouldReturnUnchangedValue ( )

Definition at line 45 of file assClozeGapTest.php.

46  {
47  // Arrange
48  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
49  $instance = new assClozeGap(0); // 0 - text gap
50  $expected = 1; // 1 - select gap
51 
52  // Act
53  $instance->setType($expected);
54  $actual = $instance->getType();
55 
56  // Assert
57  $this->assertEquals($expected, $actual);
58  }
Class for cloze question gaps.

◆ test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh()

assClozeGapTest::test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh ( )

Definition at line 387 of file assClozeGapTest.php.

388  {
389  // Arrange
390  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
391  $instance = new assClozeGap(0); // 0 - text gap
392  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
393  $item1 = new assAnswerCloze(20, 1.0, 0);
394 
395  $instance->addItem($item1);
396 
397  $expected = 40;
398 
399  // Act
400  $instance->setItemLowerBound(0, $expected);
401  $item_retrieved = $instance->getItem(0);
402  $actual = $item_retrieved->getLowerBound();
403 
404  // Assert
405  $this->assertNotEquals($expected, $actual);
406  $this->assertEquals($item_retrieved->getAnswerText(), $actual);
407  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_setItemLowerBound_shouldSetItemsLowerBound()

assClozeGapTest::test_setItemLowerBound_shouldSetItemsLowerBound ( )

Definition at line 366 of file assClozeGapTest.php.

367  {
368  // Arrange
369  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
370  $instance = new assClozeGap(0); // 0 - text gap
371  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
372  $item1 = new assAnswerCloze(20, 1.0, 0);
373 
374  $instance->addItem($item1);
375 
376  $expected = 10;
377 
378  // Act
379  $instance->setItemLowerBound(0, $expected);
380  $item_retrieved = $instance->getItem(0);
381  $actual = $item_retrieved->getLowerBound();
382 
383  // Assert
384  $this->assertEquals($expected, $actual);
385  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow()

assClozeGapTest::test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow ( )

Definition at line 430 of file assClozeGapTest.php.

431  {
432  // Arrange
433  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
434  $instance = new assClozeGap(0); // 0 - text gap
435  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
436  $item1 = new assAnswerCloze(20, 1.0, 0);
437 
438  $instance->addItem($item1);
439 
440  $expected = 10;
441 
442  // Act
443  $instance->setItemUpperBound(0, $expected);
444  $item_retrieved = $instance->getItem(0);
445  $actual = $item_retrieved->getUpperBound();
446 
447  // Assert
448  $this->assertNotEquals($expected, $actual);
449  $this->assertEquals($item_retrieved->getAnswerText(), $actual);
450  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_setItemUpperBound_shouldSetItemsUpperBound()

assClozeGapTest::test_setItemUpperBound_shouldSetItemsUpperBound ( )

Definition at line 409 of file assClozeGapTest.php.

410  {
411  // Arrange
412  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
413  $instance = new assClozeGap(0); // 0 - text gap
414  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
415  $item1 = new assAnswerCloze(5, 1.0, 0);
416 
417  $instance->addItem($item1);
418 
419  $expected = 10;
420 
421  // Act
422  $instance->setItemUpperBound(0, $expected);
423  $item_retrieved = $instance->getItem(0);
424  $actual = $item_retrieved->getUpperBound();
425 
426  // Assert
427  $this->assertEquals($expected, $actual);
428  }
Class for cloze question numeric answers.
Class for cloze question gaps.

◆ test_setType_shouldSetDefaultIfNotPassed()

assClozeGapTest::test_setType_shouldSetDefaultIfNotPassed ( )

Definition at line 60 of file assClozeGapTest.php.

61  {
62  // Arrange
63  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
64  $instance = new assClozeGap(0); // 0 - text gap
65  $expected = 0; // 0 - text gap
66 
67  // Act
68  $instance->setType();
69  $actual = $instance->getType();
70 
71  // Assert
72  $this->assertEquals($expected, $actual);
73  }
Class for cloze question gaps.

Field Documentation

◆ $backupGlobals

assClozeGapTest::$backupGlobals = false
protected

Definition at line 13 of file assClozeGapTest.php.


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