ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
assClozeSelectGapTest Class Reference

Unit tests. More...

+ Inheritance diagram for assClozeSelectGapTest:
+ Collaboration diagram for assClozeSelectGapTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_newlyInstatiatedObject_shouldReturnTrueOnGetShuffle ()
 
 test_arrayShuffle_shouldShuffleArray ()
 
 test_getItemswithShuffle_shouldReturnShuffledItems ()
 
 test_getItemswithoutShuffle_shouldReturnItemsInOrder ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 getIRSSMock ()
 

Protected Attributes

 $backupGlobals = false
 
- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Detailed Description

Unit tests.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Marvin Beym mbeym.nosp@m.@dat.nosp@m.abay..nosp@m.de

\

Definition at line 29 of file assClozeSelectGapTest.php.

Member Function Documentation

◆ setUp()

assClozeSelectGapTest::setUp ( )
protected

Definition at line 33 of file assClozeSelectGapTest.php.

33  : void
34  {
35  chdir(__DIR__ . '/../../../../');
36  }

◆ test_arrayShuffle_shouldShuffleArray()

assClozeSelectGapTest::test_arrayShuffle_shouldShuffleArray ( )

Definition at line 55 of file assClozeSelectGapTest.php.

55  : void
56  {
57  $instance = new assClozeSelectGap(1); // 1 - select gap
58  $expected = ['shfksdfs', 'sfsdf', 'sdfsdfdf'];
59 
60  $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
61  $transformationMock->expects(self::once())->method('transform')->willReturn($expected);
62  $actual = $instance->getItems($transformationMock);
63  $this->assertEquals($expected, $actual);
64  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_getItemswithoutShuffle_shouldReturnItemsInOrder()

assClozeSelectGapTest::test_getItemswithoutShuffle_shouldReturnItemsInOrder ( )

Definition at line 102 of file assClozeSelectGapTest.php.

102  : void
103  {
104  $instance = new assClozeSelectGap(1); // 1 - select gap
105  $item1 = new assAnswerCloze('Bert', 1.0, 0);
106  $item2 = new assAnswerCloze('Fred', 2.0, 1);
107  $item3 = new assAnswerCloze('Karl', 4, 2);
108  $item4 = new assAnswerCloze('Esther', 4, 3);
109 
110  $instance->addItem($item1);
111  $instance->addItem($item2);
112  $instance->addItem($item3);
113  $instance->addItem($item4);
114 
115  $instance->setType(false);
116 
117  $expected = [$item1, $item2, $item3, $item4];
118  $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
119  $transformationMock->expects(self::once())->method('transform')->willReturnCallback(function ($value) {
120  return $value;
121  });
122  $actual = $instance->getItems($transformationMock);
123 
124  $this->assertEquals($expected, $actual);
125  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_getItemswithShuffle_shouldReturnShuffledItems()

assClozeSelectGapTest::test_getItemswithShuffle_shouldReturnShuffledItems ( )

Definition at line 66 of file assClozeSelectGapTest.php.

66  : void
67  {
68  $instance = new assClozeSelectGap(1); // 1 - select gap
69  $item1 = new assAnswerCloze('Bert', 1.0, 0);
70  $item2 = new assAnswerCloze('Fred', 2.0, 2);
71  $item3 = new assAnswerCloze('Karl', 4, 1);
72  $item4 = new assAnswerCloze('Esther', 4, 3);
73  $item5 = new assAnswerCloze('Herbert', 1.0, 4);
74  $item6 = new assAnswerCloze('Karina', 1.0, 5);
75  $item7 = new assAnswerCloze('Helmut', 1.0, 6);
76  $item8 = new assAnswerCloze('Kerstin', 1.0, 7);
77 
78  $instance->addItem($item1);
79  $instance->addItem($item2);
80  $instance->addItem($item3);
81  $instance->addItem($item4);
82  $instance->addItem($item5);
83  $instance->addItem($item6);
84  $instance->addItem($item7);
85  $instance->addItem($item8);
86 
87  $instance->setType(true);
88 
89  $sequence = [$item1, $item3, $item2, $item4, $item5, $item6, $item7, $item8];
90  $expectedSequence = array_reverse($sequence);
91 
92  $randomElmProvider = $this->getMockBuilder(Transformation::class)->getMock();
93  $randomElmProvider->expects($this->once())
94  ->method('transform')
95  ->with($sequence)
96  ->willReturn($expectedSequence);
97 
98  $actual = $instance->getItems($randomElmProvider);
99  $this->assertEquals($actual, $expectedSequence);
100  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_instantiateObject_shouldReturnInstance()

assClozeSelectGapTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 38 of file assClozeSelectGapTest.php.

38  : void
39  {
40  $instance = new assClozeSelectGap(1); // 1 - select gap
41 
42  $this->assertInstanceOf(assClozeSelectGap::class, $instance);
43  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_newlyInstatiatedObject_shouldReturnTrueOnGetShuffle()

assClozeSelectGapTest::test_newlyInstatiatedObject_shouldReturnTrueOnGetShuffle ( )

Definition at line 45 of file assClozeSelectGapTest.php.

45  : void
46  {
47  $instance = new assClozeSelectGap(1); // 1 - select gap
48  $expected = true;
49 
50  $actual = $instance->getShuffle();
51 
52  $this->assertEquals($expected, $actual);
53  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $backupGlobals

assClozeSelectGapTest::$backupGlobals = false
protected

Definition at line 31 of file assClozeSelectGapTest.php.


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