17 if (
defined(
'ILIAS_PHPUNIT_CONTEXT'))
19 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
20 ilUnitUtil::performInitialisation();
24 chdir( dirname( __FILE__ ) );
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) );
32 $ilUtils = $util_mock;
38 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
43 $this->assertInstanceOf(
'assClozeGap', $instance);
49 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
54 $instance->setType($expected);
55 $actual = $instance->getType();
58 $this->assertEquals($expected, $actual);
64 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
70 $actual = $instance->getType();
73 $this->assertEquals($expected, $actual);
79 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
84 $instance->setShuffle($expected);
85 $actual = $instance->getShuffle();
88 $this->assertEquals($expected, $actual);
94 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
99 $the_unexpected =
array(
'Killing',
'Kunkel',
'Luetzenkirchen',
100 'Meyer',
'Jansen',
'Heyser',
'Becker');
101 $instance->items = $the_unexpected;
102 $instance->setShuffle(
true);
107 $this->assertNotEquals($the_unexpected, $actual);
113 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
115 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
119 $instance->addItem($expected);
120 $actual = $instance->getItem(0);
123 $this->assertEquals($expected, $actual);
129 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
131 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
136 $instance->addItem($answer);
137 $instance->addItem($expected);
138 $actual = $instance->getItem(0);
141 $this->assertEquals($expected, $actual);
147 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
149 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
153 $instance->addItem($answer1);
154 $instance->addItem($answer2);
159 $actual = $instance->getItem(2);
162 $this->assertEquals($expected, $actual);
168 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
171 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
178 $instance->addItem($answer);
179 $instance->addItem($answer2);
180 $instance->addItem($answer3);
181 $instance->addItem($expected);
182 $actual = $instance->getItem(0);
185 $this->assertEquals($expected, $actual);
191 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
193 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
198 $instance->setShuffle(
false);
199 $expected =
array($item1, $item2, $item3, $item4);
201 $instance->addItem($item1);
202 $instance->addItem($item2);
203 $instance->addItem($item3);
204 $instance->addItem($item4);
208 $this->assertEquals($expected, $actual);
214 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
216 $instance->setShuffle(
true);
217 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
226 $expected =
array($item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8);
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);
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);
255 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
257 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
262 $expected =
array($item1, $item2, $item3, $item4);
265 $instance->addItem($item1);
266 $instance->addItem($item2);
267 $instance->addItem($item3);
268 $instance->addItem($item4);
269 $actual = $instance->getItemsRaw();
272 $this->assertEquals($expected, $actual);
278 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
280 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
288 $instance->addItem($item1);
289 $instance->addItem($item2);
290 $instance->addItem($item3);
291 $instance->addItem($item4);
292 $actual = $instance->getItemCount();
295 $this->assertEquals($expected, $actual);
298 public function test_setItemPoints_shouldSetItemPoints()
301 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
303 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
305 $instance->addItem($item1);
309 $instance->setItemPoints(0, $expected);
311 $item_retrieved = $instance->getItem(0);
312 $actual = $item_retrieved->getPoints();
315 $this->assertEquals($expected, $actual);
321 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
323 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
327 $instance->addItem($item1);
328 $instance->addItem($item2);
330 $expected =
array(
'1' => $item2);
333 $instance->deleteItem(0);
335 $actual = $instance->getItemsRaw();
338 $this->assertEquals($expected, $actual);
344 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
346 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
352 $instance->addItem($item1);
353 $instance->addItem($item2);
354 $instance->addItem($item3);
355 $instance->addItem($item4);
360 $instance->clearItems();
361 $actual = $instance->getItemCount();
364 $this->assertEquals($expected, $actual);
370 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
372 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
375 $instance->addItem($item1);
380 $instance->setItemLowerBound(0, $expected);
381 $item_retrieved = $instance->getItem(0);
382 $actual = $item_retrieved->getLowerBound();
385 $this->assertEquals($expected, $actual);
391 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
393 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
396 $instance->addItem($item1);
401 $instance->setItemLowerBound(0, $expected);
402 $item_retrieved = $instance->getItem(0);
403 $actual = $item_retrieved->getLowerBound();
406 $this->assertNotEquals($expected, $actual);
407 $this->assertEquals($item_retrieved->getAnswerText(), $actual);
413 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
415 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
418 $instance->addItem($item1);
423 $instance->setItemUpperBound(0, $expected);
424 $item_retrieved = $instance->getItem(0);
425 $actual = $item_retrieved->getUpperBound();
428 $this->assertEquals($expected, $actual);
434 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
436 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
439 $instance->addItem($item1);
444 $instance->setItemUpperBound(0, $expected);
445 $item_retrieved = $instance->getItem(0);
446 $actual = $item_retrieved->getUpperBound();
449 $this->assertNotEquals($expected, $actual);
450 $this->assertEquals($item_retrieved->getAnswerText(), $actual);
456 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
458 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
464 $instance->addItem($item1);
465 $instance->addItem($item2);
466 $instance->addItem($item3);
467 $instance->addItem($item4);
469 $expected = strlen($item4->getAnswertext());
472 $actual = $instance->getMaxWidth();
475 $this->assertEquals($expected, $actual);
481 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
483 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
489 $instance->addItem($item1);
490 $instance->addItem($item2);
491 $instance->addItem($item3);
492 $instance->addItem($item4);
494 $expected =
array( 0 => 3 );
497 $actual = $instance->getBestSolutionIndexes();
500 $this->assertEquals($expected, $actual);
506 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
508 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
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') );
521 $instance->addItem($item1);
522 $instance->addItem($item2);
523 $instance->addItem($item3);
524 $instance->addItem($item4);
526 $expected =
'Esther';
532 $this->assertEquals($expected, $actual);
538 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
540 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
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') );
553 $instance->setShuffle(
true);
554 $instance->addItem($item1);
555 $instance->addItem($item2);
556 $instance->addItem($item3);
557 $instance->addItem($item4);
559 $expected1 =
'Karl or Esther';
560 $expected2 =
'Esther or Karl';
566 $this->assertTrue( ($actual == $expected1) || ($actual == $expected2) );
572 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
574 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
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') );
587 $instance->addItem($item1);
588 $instance->addItem($item2);
589 $instance->addItem($item3);
590 $instance->addItem($item4);
598 $this->assertEquals($expected, $actual);
604 require_once
'./Modules/TestQuestionPool/classes/class.assClozeGap.php';
606 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
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') );
619 $instance->addItem($item1);
620 $instance->addItem($item2);
621 $instance->addItem($item3);
622 $instance->addItem($item4);
630 $this->assertEquals($expected, $actual);
Class for cloze question numeric answers.
test_addGetItem_shouldReturnValueUnchanged()
test_getItemsWithShuffle_shouldReturnItemsAddedShuffled()
test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext()
test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric()
test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti()
test_instantiateObject_shouldReturnInstance()
test_setType_shouldSetDefaultIfNotPassed()
Class for cloze question gaps.
test_getItemsRaw_shouldReturnItemsAdded()
test_addGetItem_shouldReturnValueUnchangedMultiplePlus()
test_clearItems_shouldClearItems()
test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow()
test_deleteItem_shouldDeleteGivenItem()
test_setItemLowerBound_shouldSetItemsLowerBound()
test_getItemCount_shouldReturnCorrectCount()
test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes()
test_setItemUpperBound_shouldSetItemsUpperBound()
Create styles array
The data for the language used.
test_arrayShuffle_shouldNotReturnArrayUnshuffled()
test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText()
test_getItem_shouldReturnNullIfNoItemAtGivenIndex()
test_getItems_shouldReturnItemsAdded()
test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK()
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
test_addGetItem_shouldReturnValueUnchangedMultiple()
test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh()
test_setGetType_shouldReturnUnchangedValue()
test_setGetShuffle_shouldReturnUnchangedValue()