ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 28 of file assClozeSelectGapTest.php.

Member Function Documentation

◆ setUp()

assClozeSelectGapTest::setUp ( )
protected

Definition at line 32 of file assClozeSelectGapTest.php.

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

◆ test_arrayShuffle_shouldShuffleArray()

assClozeSelectGapTest::test_arrayShuffle_shouldShuffleArray ( )

Definition at line 54 of file assClozeSelectGapTest.php.

54  : void
55  {
56  $instance = new assClozeSelectGap(1); // 1 - select gap
57  $expected = ['shfksdfs', 'sfsdf', 'sdfsdfdf'];
58 
59  $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
60  $transformationMock->expects(self::once())->method('transform')->willReturn($expected);
61  $actual = $instance->getItems($transformationMock);
62  $this->assertEquals($expected, $actual);
63  }
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 101 of file assClozeSelectGapTest.php.

101  : void
102  {
103  $instance = new assClozeSelectGap(1); // 1 - select gap
104  $item1 = new assAnswerCloze('Bert', 1.0, 0);
105  $item2 = new assAnswerCloze('Fred', 2.0, 1);
106  $item3 = new assAnswerCloze('Karl', 4, 2);
107  $item4 = new assAnswerCloze('Esther', 4, 3);
108 
109  $instance->addItem($item1);
110  $instance->addItem($item2);
111  $instance->addItem($item3);
112  $instance->addItem($item4);
113 
114  $instance->setType(false);
115 
116  $expected = [$item1, $item2, $item3, $item4];
117  $transformationMock = $this->getMockBuilder(Transformation::class)->getMock();
118  $transformationMock->expects(self::once())->method('transform')->willReturnCallback(function ($value) {
119  return $value;
120  });
121  $actual = $instance->getItems($transformationMock);
122 
123  $this->assertEquals($expected, $actual);
124  }
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 65 of file assClozeSelectGapTest.php.

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

37  : void
38  {
39  $instance = new assClozeSelectGap(1); // 1 - select gap
40 
41  $this->assertInstanceOf(assClozeSelectGap::class, $instance);
42  }
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 44 of file assClozeSelectGapTest.php.

44  : void
45  {
46  $instance = new assClozeSelectGap(1); // 1 - select gap
47  $expected = true;
48 
49  $actual = $instance->getShuffle();
50 
51  $this->assertEquals($expected, $actual);
52  }
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 30 of file assClozeSelectGapTest.php.


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