ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 setGlobalVariable (string $name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIRSSMock ()
 
 getFileDeliveryMock ()
 
 getIliasMock ()
 
 addGlobal_uiFactory ()
 
 addGlobal_uiRenderer ()
 

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(dirname(__FILE__));
35  chdir('../../../');
36  }

◆ test_arrayShuffle_shouldShuffleArray()

assClozeSelectGapTest::test_arrayShuffle_shouldShuffleArray ( )

Definition at line 56 of file assClozeSelectGapTest.php.

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

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

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

46  : void
47  {
48  $instance = new assClozeSelectGap(1); // 1 - select gap
49  $expected = true;
50 
51  $actual = $instance->getShuffle();
52 
53  $this->assertEquals($expected, $actual);
54  }
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: