ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
assLongmenuTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assLongmenuTest:
+ Collaboration diagram for assLongmenuTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_getAdditionalTableName_shouldReturnString ()
 
 test_getQuestionType_shouldReturnString ()
 
 test_getAnswerTableName_shouldReturnString ()
 
 test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ()
 
 test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ()
 
 test_getMaximumPoints_shouldBeFour ()
 
 test_getMaximumPoints_shouldBeFourPointFive ()
 
 test_isComplete_shouldBeFalse ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ()
 
 test_checkQuestionCustomPart_shouldBeTrue ()
 
 test_setAnswerType_shouldReturnGetAnswerType ()
 
 test_isShuffleAnswersEnabled_shouldReturnFalse ()
 

Protected Member Functions

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

Static Protected Member Functions

static getMethod ($name)
 

Protected Attributes

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Unit tests

Author
Guido Vollbach <gvollbachdatabay.de>

\

Definition at line 26 of file assLongMenuTest.php.

Member Function Documentation

◆ getMethod()

static assLongmenuTest::getMethod (   $name)
staticprotected

Definition at line 31 of file assLongMenuTest.php.

32  {
33  $class = new ReflectionClass(assLongMenu::class);
34  $method = $class->getMethod($name);
35  $method->setAccessible(true);
36  return $method;
37  }

◆ setUp()

assLongmenuTest::setUp ( )
protected

Definition at line 39 of file assLongMenuTest.php.

References getDatabaseMock(), getIliasMock(), and setGlobalVariable().

39  : void
40  {
41  chdir(__DIR__ . '/../../../../');
42 
43  parent::setUp();
44 
45  $ilCtrl_mock = $this->createMock('ilCtrl');
46  $ilCtrl_mock->expects($this->any())->method('saveParameter');
47  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
48  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
49 
50  $lng_mock = $this->createMock('ilLanguage', ['txt'], [], '', false);
51  $this->setGlobalVariable('lng', $lng_mock);
52 
53  $this->setGlobalVariable('ilias', $this->getIliasMock());
54  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
55  }
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ( )

Definition at line 160 of file assLongMenuTest.php.

160  : void
161  {
162  $obj = new assLongMenu();
163  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1']]);
164  $obj->setAnswers([[1]]);
165  $this->assertEquals($obj->checkQuestionCustomPart(), false);
166  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ( )

Definition at line 168 of file assLongMenuTest.php.

168  : void
169  {
170  $obj = new assLongMenu();
171  $obj->setCorrectAnswers([0 => [0 => [], 1 => '2.25', 2 => '1']]);
172  $obj->setAnswers([['answer']]);
173  $this->assertEquals($obj->checkQuestionCustomPart(), false);
174  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ( )

Definition at line 176 of file assLongMenuTest.php.

176  : void
177  {
178  $obj = new assLongMenu();
179  $obj->setCorrectAnswers([0 => [0 => []]]);
180  $obj->setAnswers([['answer']]);
181  $this->assertEquals($obj->checkQuestionCustomPart(), false);
182  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ( )

Definition at line 184 of file assLongMenuTest.php.

184  : void
185  {
186  $obj = new assLongMenu();
187  $obj->setCorrectAnswers([0 => [0 => ['answer'], 1 => 0, 2 => '1']]);
188  $obj->setAnswers([['answer']]);
189  $this->assertEquals($obj->checkQuestionCustomPart(), false);
190  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ( )

Definition at line 134 of file assLongMenuTest.php.

134  : void
135  {
136  $obj = new assLongMenu();
137  $this->assertEquals($obj->checkQuestionCustomPart(), false);
138  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ( )

Definition at line 140 of file assLongMenuTest.php.

140  : void
141  {
142  $obj = new assLongMenu();
143  $obj->setAnswers([[1,2,3,4]]);
144  $this->assertEquals($obj->checkQuestionCustomPart(), false);
145  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ( )

Definition at line 147 of file assLongMenuTest.php.

147  : void
148  {
149  $obj = new assLongMenu();
150  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1'], 1 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1']]);
151  $this->assertEquals($obj->checkQuestionCustomPart(), false);
152  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ( )

Definition at line 153 of file assLongMenuTest.php.

153  : void
154  {
155  $obj = new assLongMenu();
156  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1'], 1 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1']]);
157  $obj->setAnswers([['answer']]);
158  $this->assertEquals($obj->checkQuestionCustomPart(), false);
159  }

◆ test_checkQuestionCustomPart_shouldBeTrue()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeTrue ( )

Definition at line 192 of file assLongMenuTest.php.

192  : void
193  {
194  $obj = new assLongMenu();
195  $obj->setCorrectAnswers([0 => [0 => ['answer'], 1 => 1, 2 => '1']]);
196  $obj->setAnswers([['answer']]);
197  $this->assertEquals($obj->checkQuestionCustomPart(), true);
198  }

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ( )

Definition at line 89 of file assLongMenuTest.php.

89  : void
90  {
91  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
92  $obj = new assLongMenu();
93  $value = $method->invokeArgs($obj, [[[1],1,1], [1,2,3,4]]);
94  $this->assertEquals(false, $value);
95  }

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ( )

Definition at line 81 of file assLongMenuTest.php.

81  : void
82  {
83  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
84  $obj = new assLongMenu();
85  $value = $method->invokeArgs($obj, [[[5],1,1], [1,2,3,4]]);
86  $this->assertEquals(true, $value);
87  }

◆ test_getAdditionalTableName_shouldReturnString()

assLongmenuTest::test_getAdditionalTableName_shouldReturnString ( )

Definition at line 63 of file assLongMenuTest.php.

63  : void
64  {
65  $instance = new assLongMenu();
66  $this->assertEquals('qpl_qst_lome', $instance->getAdditionalTableName());
67  }

◆ test_getAnswerTableName_shouldReturnString()

assLongmenuTest::test_getAnswerTableName_shouldReturnString ( )

Definition at line 75 of file assLongMenuTest.php.

75  : void
76  {
77  $instance = new assLongMenu();
78  $this->assertEquals('qpl_a_lome', $instance->getAnswerTableName());
79  }

◆ test_getMaximumPoints_shouldBeFour()

assLongmenuTest::test_getMaximumPoints_shouldBeFour ( )

Definition at line 97 of file assLongMenuTest.php.

97  : void
98  {
99  $obj = new assLongMenu();
100  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2', 2 => '1'], 1 => [0 => [0 => 'answer'], 1 => '2', 2 => '1']]);
101  $value = $obj->getMaximumPoints();
102  $this->assertEquals(4, $value);
103  }

◆ test_getMaximumPoints_shouldBeFourPointFive()

assLongmenuTest::test_getMaximumPoints_shouldBeFourPointFive ( )

Definition at line 105 of file assLongMenuTest.php.

105  : void
106  {
107  $obj = new assLongMenu();
108  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1'], 1 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1']]);
109  $value = $obj->getMaximumPoints();
110  $this->assertEquals(4.5, $value);
111  }

◆ test_getQuestionType_shouldReturnString()

assLongmenuTest::test_getQuestionType_shouldReturnString ( )

Definition at line 69 of file assLongMenuTest.php.

69  : void
70  {
71  $instance = new assLongMenu();
72  $this->assertEquals('assLongMenu', $instance->getQuestionType());
73  }

◆ test_instantiateObject_shouldReturnInstance()

assLongmenuTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 57 of file assLongMenuTest.php.

57  : void
58  {
59  $instance = new assLongMenu();
60  $this->assertInstanceOf(assLongMenu::class, $instance);
61  }

◆ test_isComplete_shouldBeFalse()

assLongmenuTest::test_isComplete_shouldBeFalse ( )

Definition at line 113 of file assLongMenuTest.php.

113  : void
114  {
115  $obj = new assLongMenu();
116  $obj->setCorrectAnswers([0 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1'], 1 => [0 => [0 => 'answer'], 1 => '2.25', 2 => '1']]);
117  $obj->setAnswers([[1,2,3,4]]);
118  $this->assertEquals($obj->isComplete(), false);
119  }

◆ test_isShuffleAnswersEnabled_shouldReturnFalse()

assLongmenuTest::test_isShuffleAnswersEnabled_shouldReturnFalse ( )

Definition at line 216 of file assLongMenuTest.php.

216  : void
217  {
218  $obj = new assLongMenu();
219  $this->assertEquals(false, $obj->isShuffleAnswersEnabled());
220  $this->assertNotEquals(true, $obj->isShuffleAnswersEnabled());
221  }

◆ test_setAnswerType_shouldReturnGetAnswerType()

assLongmenuTest::test_setAnswerType_shouldReturnGetAnswerType ( )

Definition at line 200 of file assLongMenuTest.php.

200  : void
201  {
202  $obj = new assLongMenu();
203  $obj->setAnswerType([]);
204  $this->assertEquals([], $obj->getAnswerType());
205  }

Field Documentation

◆ $backupGlobals

assLongmenuTest::$backupGlobals = false
protected

Definition at line 28 of file assLongMenuTest.php.


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