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

16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT'))
18  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir( dirname( __FILE__ ) );
25  chdir('../../../');
26  }
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  require_once './Services/Randomization/classes/class.ilArrayElementShuffler.php';
29  $util_mock = $this->getMock('ilUtil', array('stripSlashes'), array(), '', false);
30  $util_mock->expects( $this->any() )->method( 'stripSlashes' )->will( $this->returnArgument(0) );
31  global $ilUtils;
32  $ilUtils = $util_mock;
33  }
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ test_addGetItem_shouldReturnValueUnchanged()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchanged ( )

Definition at line 110 of file assClozeGapTest.php.

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

◆ test_addGetItem_shouldReturnValueUnchangedMultiple()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiple ( )

Definition at line 126 of file assClozeGapTest.php.

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

◆ test_addGetItem_shouldReturnValueUnchangedMultiplePlus()

assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiplePlus ( )

Definition at line 165 of file assClozeGapTest.php.

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

◆ test_arrayShuffle_shouldNotReturnArrayUnshuffled()

assClozeGapTest::test_arrayShuffle_shouldNotReturnArrayUnshuffled ( )

Definition at line 91 of file assClozeGapTest.php.

References array.

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

◆ test_clearItems_shouldClearItems()

assClozeGapTest::test_clearItems_shouldClearItems ( )

Definition at line 341 of file assClozeGapTest.php.

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

◆ test_deleteItem_shouldDeleteGivenItem()

assClozeGapTest::test_deleteItem_shouldDeleteGivenItem ( )

Definition at line 318 of file assClozeGapTest.php.

References array.

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

◆ test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes()

assClozeGapTest::test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes ( )

Definition at line 478 of file assClozeGapTest.php.

References array.

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

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric ( )

Definition at line 569 of file assClozeGapTest.php.

References $lng, and array.

570  {
571  // Arrange
572  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
573  $instance = new assClozeGap(2); // 0 - text gap
574  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
575  $item1 = new assAnswerCloze(10, 1.0, 0);
576  $item2 = new assAnswerCloze(20, 2.0, 2);
577  $item3 = new assAnswerCloze(30, 3.0, 1);
578  $item4 = new assAnswerCloze(100, 4.0, 3);
579 
580  // We need the $lng-mock.
581  require_once './Services/Language/classes/class.ilLanguage.php';
582  $lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
583  $lng_mock->expects( $this->any() )->method( 'txt' )->will( $this->returnValue('Test') );
584  global $lng;
585  $lng = $lng_mock;
586 
587  $instance->addItem($item1);
588  $instance->addItem($item2);
589  $instance->addItem($item3);
590  $instance->addItem($item4);
591 
592  $expected = 100;
593 
594  // Act
595  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
596 
597  // Assert
598  $this->assertEquals($expected, $actual);
599  }
Class for cloze question numeric answers.
Class for cloze question gaps.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText ( )

Definition at line 503 of file assClozeGapTest.php.

References $lng, and array.

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

◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti ( )

Definition at line 535 of file assClozeGapTest.php.

References $lng, and array.

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

◆ test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK()

assClozeGapTest::test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK ( )

Definition at line 601 of file assClozeGapTest.php.

References $lng, and array.

602  {
603  // Arrange
604  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
605  $instance = new assClozeGap(11); // 0 - text gap
606  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
607  $item1 = new assAnswerCloze(10, 1.0, 0);
608  $item2 = new assAnswerCloze(20, 2.0, 2);
609  $item3 = new assAnswerCloze(30, 3.0, 1);
610  $item4 = new assAnswerCloze(100, 4.0, 3);
611 
612  // We need the $lng-mock.
613  require_once './Services/Language/classes/class.ilLanguage.php';
614  $lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
615  $lng_mock->expects( $this->any() )->method( 'txt' )->will( $this->returnValue('Test') );
616  global $lng;
617  $lng = $lng_mock;
618 
619  $instance->addItem($item1);
620  $instance->addItem($item2);
621  $instance->addItem($item3);
622  $instance->addItem($item4);
623 
624  $expected = '';
625 
626  // Act
627  $actual = $instance->getBestSolutionOutput(new ilArrayElementShuffler);
628 
629  // Assert
630  $this->assertEquals($expected, $actual);
631  }
Class for cloze question numeric answers.
Class for cloze question gaps.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

◆ test_getItem_shouldReturnNullIfNoItemAtGivenIndex()

assClozeGapTest::test_getItem_shouldReturnNullIfNoItemAtGivenIndex ( )

Definition at line 144 of file assClozeGapTest.php.

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

◆ test_getItemCount_shouldReturnCorrectCount()

assClozeGapTest::test_getItemCount_shouldReturnCorrectCount ( )

Definition at line 275 of file assClozeGapTest.php.

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

◆ test_getItems_shouldReturnItemsAdded()

assClozeGapTest::test_getItems_shouldReturnItemsAdded ( )

Definition at line 188 of file assClozeGapTest.php.

References array.

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

◆ test_getItemsRaw_shouldReturnItemsAdded()

assClozeGapTest::test_getItemsRaw_shouldReturnItemsAdded ( )

Definition at line 252 of file assClozeGapTest.php.

References array.

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

◆ test_getItemsWithShuffle_shouldReturnItemsAddedShuffled()

assClozeGapTest::test_getItemsWithShuffle_shouldReturnItemsAddedShuffled ( )

Definition at line 211 of file assClozeGapTest.php.

References array.

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

◆ test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext()

assClozeGapTest::test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext ( )

Definition at line 453 of file assClozeGapTest.php.

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

◆ test_instantiateObject_shouldReturnInstance()

assClozeGapTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 35 of file assClozeGapTest.php.

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

◆ test_setGetShuffle_shouldReturnUnchangedValue()

assClozeGapTest::test_setGetShuffle_shouldReturnUnchangedValue ( )

Definition at line 76 of file assClozeGapTest.php.

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

◆ test_setGetType_shouldReturnUnchangedValue()

assClozeGapTest::test_setGetType_shouldReturnUnchangedValue ( )

Definition at line 46 of file assClozeGapTest.php.

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

◆ test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh()

assClozeGapTest::test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh ( )

Definition at line 388 of file assClozeGapTest.php.

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

◆ test_setItemLowerBound_shouldSetItemsLowerBound()

assClozeGapTest::test_setItemLowerBound_shouldSetItemsLowerBound ( )

Definition at line 367 of file assClozeGapTest.php.

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

◆ test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow()

assClozeGapTest::test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow ( )

Definition at line 431 of file assClozeGapTest.php.

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

◆ test_setItemUpperBound_shouldSetItemsUpperBound()

assClozeGapTest::test_setItemUpperBound_shouldSetItemsUpperBound ( )

Definition at line 410 of file assClozeGapTest.php.

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

◆ test_setType_shouldSetDefaultIfNotPassed()

assClozeGapTest::test_setType_shouldSetDefaultIfNotPassed ( )

Definition at line 61 of file assClozeGapTest.php.

62  {
63  // Arrange
64  require_once './Modules/TestQuestionPool/classes/class.assClozeGap.php';
65  $instance = new assClozeGap(0); // 0 - text gap
66  $expected = 0; // 0 - text gap
67 
68  // Act
69  $instance->setType();
70  $actual = $instance->getType();
71 
72  // Assert
73  $this->assertEquals($expected, $actual);
74  }
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: