Unit tests.
More...
Unit tests.
- Author
- Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Definition at line 28 of file assClozeGapTest.php.
◆ getDummyTransformationMock()
| assClozeGapTest::getDummyTransformationMock |
( |
| ) |
|
|
private |
◆ setUp()
| assClozeGapTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 32 of file assClozeGapTest.php.
References assBaseTestCase\setGlobalVariable().
34 chdir(dirname(__FILE__));
39 $util_mock = $this->createMock(
'ilUtil', array(
'stripSlashes'), array(),
'',
false);
40 $util_mock->expects($this->any())->method(
'stripSlashes')->will($this->returnArgument(0));
setGlobalVariable(string $name, $value)
◆ test_addGetItem_shouldReturnValueUnchanged()
| assClozeGapTest::test_addGetItem_shouldReturnValueUnchanged |
( |
| ) |
|
Definition at line 110 of file assClozeGapTest.php.
116 $instance->addItem($expected);
117 $actual = $instance->getItem(0);
120 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_addGetItem_shouldReturnValueUnchangedMultiple()
| assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiple |
( |
| ) |
|
Definition at line 123 of file assClozeGapTest.php.
130 $instance->addItem($answer);
131 $instance->addItem($expected);
132 $actual = $instance->getItem(0);
135 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_addGetItem_shouldReturnValueUnchangedMultiplePlus()
| assClozeGapTest::test_addGetItem_shouldReturnValueUnchangedMultiplePlus |
( |
| ) |
|
Definition at line 156 of file assClozeGapTest.php.
165 $instance->addItem($answer);
166 $instance->addItem($answer2);
167 $instance->addItem($answer3);
168 $instance->addItem($expected);
169 $actual = $instance->getItem(0);
172 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_arrayShuffle_shouldNotReturnArrayUnshuffled()
| assClozeGapTest::test_arrayShuffle_shouldNotReturnArrayUnshuffled |
( |
| ) |
|
Definition at line 91 of file assClozeGapTest.php.
96 $the_unexpected = array(
'Killing',
'Kunkel',
'Luetzenkirchen',
97 'Meyer',
'Jansen',
'Heyser',
'Becker');
98 $instance->items = $the_unexpected;
99 $instance->setShuffle(
true);
100 $theExpected = [
'hua',
'haaa',
'some random values'];
102 $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
103 $transformationMock->expects(self::once())->method(
'transform')->with($the_unexpected)->willReturn($theExpected);
104 $actual = $instance->getItems($transformationMock);
107 $this->assertEquals($theExpected, $actual);
Class for cloze question gaps.
◆ test_clearItems_shouldClearItems()
| assClozeGapTest::test_clearItems_shouldClearItems |
( |
| ) |
|
Definition at line 305 of file assClozeGapTest.php.
313 $instance->addItem($item1);
314 $instance->addItem($item2);
315 $instance->addItem($item3);
316 $instance->addItem($item4);
321 $instance->clearItems();
322 $actual = $instance->getItemCount();
325 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_deleteItem_shouldDeleteGivenItem()
| assClozeGapTest::test_deleteItem_shouldDeleteGivenItem |
( |
| ) |
|
Definition at line 285 of file assClozeGapTest.php.
291 $instance->addItem($item1);
292 $instance->addItem($item2);
294 $expected = array(
'1' => $item2);
297 $instance->deleteItem(0);
299 $actual = $instance->getItemsRaw();
302 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes()
| assClozeGapTest::test_getBestSolutionIndexes_shouldReturnBestSolutionIndexes |
( |
| ) |
|
Definition at line 424 of file assClozeGapTest.php.
432 $instance->addItem($item1);
433 $instance->addItem($item2);
434 $instance->addItem($item3);
435 $instance->addItem($item4);
437 $expected = array( 0 => 3 );
440 $actual = $instance->getBestSolutionIndexes();
443 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric()
| assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseNumeric |
( |
| ) |
|
Definition at line 506 of file assClozeGapTest.php.
References $DIC, $GLOBALS, and getDummyTransformationMock().
515 $lng_mock = $this->createMock(
'ilLanguage', array(
'txt'), array(),
'',
false);
516 $lng_mock->expects($this->any())->method(
'txt')->will($this->returnValue(
'Test'));
519 $DIC[
'lng'] = $lng_mock;
522 $instance->addItem($item1);
523 $instance->addItem($item2);
524 $instance->addItem($item3);
525 $instance->addItem($item4);
533 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
getDummyTransformationMock()
◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText()
| assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseText |
( |
| ) |
|
Definition at line 446 of file assClozeGapTest.php.
References $DIC, $GLOBALS, and getDummyTransformationMock().
454 $lng_mock = $this->createMock(
'ilLanguage', array(
'txt'), array(),
'',
false);
455 $lng_mock->expects($this->any())->method(
'txt')->will($this->returnValue(
'Test'));
458 $DIC[
'lng'] = $lng_mock;
461 $instance->addItem($item1);
462 $instance->addItem($item2);
463 $instance->addItem($item3);
464 $instance->addItem($item4);
466 $expected =
'Esther';
472 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
getDummyTransformationMock()
◆ test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti()
| assClozeGapTest::test_getBestSolutionOutput_shouldReturnBestSolutionOutput_CaseTextMulti |
( |
| ) |
|
Definition at line 475 of file assClozeGapTest.php.
References $DIC, $GLOBALS, and getDummyTransformationMock().
483 $lng_mock = $this->createMock(
'ilLanguage', array(
'txt'), array(),
'',
false);
484 $lng_mock->expects($this->any())->method(
'txt')->will($this->returnValue(
'or'));
487 $DIC[
'lng'] = $lng_mock;
490 $instance->setShuffle(
true);
491 $instance->addItem($item1);
492 $instance->addItem($item2);
493 $instance->addItem($item3);
494 $instance->addItem($item4);
496 $expected1 =
'Karl or Esther';
497 $expected2 =
'Esther or Karl';
503 $this->assertTrue(($actual == $expected1) || ($actual == $expected2));
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
getDummyTransformationMock()
◆ test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK()
| assClozeGapTest::test_getBestSolutionOutput_shouldReturnEmptyStringOnUnknownType_WhichMakesNoSenseButK |
( |
| ) |
|
Definition at line 536 of file assClozeGapTest.php.
References $DIC, $GLOBALS, and getDummyTransformationMock().
544 $lng_mock = $this->createMock(
'ilLanguage', array(
'txt'), array(),
'',
false);
545 $lng_mock->expects($this->any())->method(
'txt')->will($this->returnValue(
'Test'));
548 $DIC[
'lng'] = $lng_mock;
551 $instance->addItem($item1);
552 $instance->addItem($item2);
553 $instance->addItem($item3);
554 $instance->addItem($item4);
562 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
getDummyTransformationMock()
◆ test_getItem_shouldReturnNullIfNoItemAtGivenIndex()
| assClozeGapTest::test_getItem_shouldReturnNullIfNoItemAtGivenIndex |
( |
| ) |
|
Definition at line 138 of file assClozeGapTest.php.
144 $instance->addItem($answer1);
145 $instance->addItem($answer2);
150 $actual = $instance->getItem(2);
153 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getItemCount_shouldReturnCorrectCount()
| assClozeGapTest::test_getItemCount_shouldReturnCorrectCount |
( |
| ) |
|
Definition at line 248 of file assClozeGapTest.php.
258 $instance->addItem($item1);
259 $instance->addItem($item2);
260 $instance->addItem($item3);
261 $instance->addItem($item4);
262 $actual = $instance->getItemCount();
265 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getItems_shouldReturnItemsAdded()
| assClozeGapTest::test_getItems_shouldReturnItemsAdded |
( |
| ) |
|
Definition at line 175 of file assClozeGapTest.php.
182 $instance->setShuffle(
false);
183 $expected = array($item1, $item2, $item3, $item4);
185 $instance->addItem($item1);
186 $instance->addItem($item2);
187 $instance->addItem($item3);
188 $instance->addItem($item4);
189 $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
190 $transformationMock->expects(self::never())->method(
'transform');
191 $actual = $instance->getItems($transformationMock);
194 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getItemsRaw_shouldReturnItemsAdded()
| assClozeGapTest::test_getItemsRaw_shouldReturnItemsAdded |
( |
| ) |
|
Definition at line 228 of file assClozeGapTest.php.
235 $expected = array($item1, $item2, $item3, $item4);
238 $instance->addItem($item1);
239 $instance->addItem($item2);
240 $instance->addItem($item3);
241 $instance->addItem($item4);
242 $actual = $instance->getItemsRaw();
245 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getItemsWithShuffle_shouldReturnItemsAddedShuffled()
| assClozeGapTest::test_getItemsWithShuffle_shouldReturnItemsAddedShuffled |
( |
| ) |
|
Definition at line 197 of file assClozeGapTest.php.
200 $instance->setShuffle(
true);
212 $shuffledArray = [
'some shuffled array',
'these values dont matter'];
215 foreach ($expected as $item) {
216 $instance->addItem($item);
219 $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
220 $transformationMock->expects(self::once())->method(
'transform')->with($expected)->willReturn($shuffledArray);
221 $actual = $instance->getItems($transformationMock);
225 $this->assertEquals($shuffledArray, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext()
| assClozeGapTest::test_getMaxWidth_shouldReturnCharacterCountOfLongestAnswertext |
( |
| ) |
|
Definition at line 402 of file assClozeGapTest.php.
410 $instance->addItem($item1);
411 $instance->addItem($item2);
412 $instance->addItem($item3);
413 $instance->addItem($item4);
415 $expected = strlen($item4->getAnswertext());
418 $actual = $instance->getMaxWidth();
421 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_instantiateObject_shouldReturnInstance()
| assClozeGapTest::test_instantiateObject_shouldReturnInstance |
( |
| ) |
|
Definition at line 44 of file assClozeGapTest.php.
49 $this->assertInstanceOf(
'assClozeGap', $instance);
Class for cloze question gaps.
◆ test_setGetShuffle_shouldReturnUnchangedValue()
| assClozeGapTest::test_setGetShuffle_shouldReturnUnchangedValue |
( |
| ) |
|
Definition at line 78 of file assClozeGapTest.php.
84 $instance->setShuffle($expected);
85 $actual = $instance->getShuffle();
88 $this->assertEquals($expected, $actual);
Class for cloze question gaps.
◆ test_setGetType_shouldReturnUnchangedValue()
| assClozeGapTest::test_setGetType_shouldReturnUnchangedValue |
( |
| ) |
|
Definition at line 52 of file assClozeGapTest.php.
58 $instance->setType($expected);
59 $actual = $instance->getType();
62 $this->assertEquals($expected, $actual);
Class for cloze question gaps.
◆ test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh()
| assClozeGapTest::test_setItemLowerBound_shouldSetItemsAnswerIfBoundTooHigh |
( |
| ) |
|
Definition at line 346 of file assClozeGapTest.php.
351 $instance->addItem($item1);
356 $instance->setItemLowerBound(0, $expected);
357 $item_retrieved = $instance->getItem(0);
358 $actual = $item_retrieved->getLowerBound();
361 $this->assertNotEquals($expected, $actual);
362 $this->assertEquals($item_retrieved->getAnswerText(), $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_setItemLowerBound_shouldSetItemsLowerBound()
| assClozeGapTest::test_setItemLowerBound_shouldSetItemsLowerBound |
( |
| ) |
|
Definition at line 328 of file assClozeGapTest.php.
333 $instance->addItem($item1);
338 $instance->setItemLowerBound(0, $expected);
339 $item_retrieved = $instance->getItem(0);
340 $actual = $item_retrieved->getLowerBound();
343 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow()
| assClozeGapTest::test_setItemUpperBound_shouldSetItemsAnswerIfBoundTooLow |
( |
| ) |
|
Definition at line 383 of file assClozeGapTest.php.
388 $instance->addItem($item1);
393 $instance->setItemUpperBound(0, $expected);
394 $item_retrieved = $instance->getItem(0);
395 $actual = $item_retrieved->getUpperBound();
398 $this->assertNotEquals($expected, $actual);
399 $this->assertEquals($item_retrieved->getAnswerText(), $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_setItemUpperBound_shouldSetItemsUpperBound()
| assClozeGapTest::test_setItemUpperBound_shouldSetItemsUpperBound |
( |
| ) |
|
Definition at line 365 of file assClozeGapTest.php.
370 $instance->addItem($item1);
375 $instance->setItemUpperBound(0, $expected);
376 $item_retrieved = $instance->getItem(0);
377 $actual = $item_retrieved->getUpperBound();
380 $this->assertEquals($expected, $actual);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for cloze question gaps.
◆ test_setType_shouldSetDefaultIfNotPassed()
| assClozeGapTest::test_setType_shouldSetDefaultIfNotPassed |
( |
| ) |
|
Definition at line 65 of file assClozeGapTest.php.
72 $actual = $instance->getType();
75 $this->assertEquals($expected, $actual);
Class for cloze question gaps.
◆ $backupGlobals
| assClozeGapTest::$backupGlobals = false |
|
protected |
The documentation for this class was generated from the following file: