ILIAS  release_8 Revision v8.24
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_getSolutionSubmit_shouldReturnSolution ()
 
 test_setAnswerType_shouldReturnGetAnswerType ()
 
 test_setJsonStructure_shouldReturnGetJsonStructure ()
 
 test_isShuffleAnswersEnabled_shouldReturnFalse ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

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 25 of file assLongMenuTest.php.

Member Function Documentation

◆ getMethod()

static assLongmenuTest::getMethod (   $name)
staticprotected

Definition at line 30 of file assLongMenuTest.php.

30 : ReflectionMethod
31 {
32 $class = new ReflectionClass('assLongMenu');
33 $method = $class->getMethod($name);
34 $method->setAccessible(true);
35 return $method;
36 }
if($format !==null) $name
Definition: metadata.php:247

References $name.

Referenced by test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse(), and test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue().

+ Here is the caller graph for this function:

◆ setUp()

assLongmenuTest::setUp ( )
protected

Reimplemented from assBaseTestCase.

Definition at line 38 of file assLongMenuTest.php.

38 : void
39 {
40 chdir(dirname(__FILE__));
41 chdir('../../../');
42
43 parent::setUp();
44
45 require_once './Services/UICore/classes/class.ilCtrl.php';
46 $ilCtrl_mock = $this->createMock('ilCtrl');
47 $ilCtrl_mock->expects($this->any())->method('saveParameter');
48 $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
49 $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
50
51 require_once './Services/Language/classes/class.ilLanguage.php';
52 $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
53 //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
54 $this->setGlobalVariable('lng', $lng_mock);
55
56 $this->setGlobalVariable('ilias', $this->getIliasMock());
57 $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
58 $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
59 }
setGlobalVariable(string $name, $value)

References assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

+ Here is the call graph for this function:

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ( )

Definition at line 170 of file assLongMenuTest.php.

170 : void
171 {
172 $obj = new assLongMenu();
173 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
174 $obj->setAnswers(array(array(1)));
175 $this->assertEquals($obj->checkQuestionCustomPart(), false);
176 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ( )

Definition at line 178 of file assLongMenuTest.php.

178 : void
179 {
180 $obj = new assLongMenu();
181 $obj->setCorrectAnswers(array( 0 => array( 0 => array(),1 => '2.25', 2 => '1')));
182 $obj->setAnswers(array(array('answer')));
183 $this->assertEquals($obj->checkQuestionCustomPart(), false);
184 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ( )

Definition at line 186 of file assLongMenuTest.php.

186 : void
187 {
188 $obj = new assLongMenu();
189 $obj->setCorrectAnswers(array( 0 => array( 0 => array())));
190 $obj->setAnswers(array(array('answer')));
191 $this->assertEquals($obj->checkQuestionCustomPart(), false);
192 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ( )

Definition at line 194 of file assLongMenuTest.php.

194 : void
195 {
196 $obj = new assLongMenu();
197 $obj->setCorrectAnswers(array( 0 => array( 0 => array('answer'),1 => 0, 2 => '1')));
198 $obj->setAnswers(array(array('answer')));
199 $this->assertEquals($obj->checkQuestionCustomPart(), false);
200 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ( )

Definition at line 142 of file assLongMenuTest.php.

142 : void
143 {
144 $obj = new assLongMenu();
145 $this->assertEquals($obj->checkQuestionCustomPart(), false);
146 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ( )

Definition at line 148 of file assLongMenuTest.php.

148 : void
149 {
150 $obj = new assLongMenu();
151 $obj->setAnswers(array(array(1,2,3,4)));
152 $this->assertEquals($obj->checkQuestionCustomPart(), false);
153 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ( )

Definition at line 155 of file assLongMenuTest.php.

155 : void
156 {
157 $obj = new assLongMenu();
158 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
159 1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
160 $this->assertEquals($obj->checkQuestionCustomPart(), false);
161 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ( )

Definition at line 162 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeTrue()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeTrue ( )

Definition at line 202 of file assLongMenuTest.php.

202 : void
203 {
204 $obj = new assLongMenu();
205 $obj->setCorrectAnswers(array( 0 => array( 0 => array('answer'),1 => 1, 2 => '1')));
206 $obj->setAnswers(array(array('answer')));
207 $this->assertEquals($obj->checkQuestionCustomPart(), true);
208 }

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ( )

Definition at line 93 of file assLongMenuTest.php.

93 : void
94 {
95 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
96 $obj = new assLongMenu();
97 $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
98 $this->assertEquals(false, $value);
99 }
static getMethod($name)

References getMethod().

+ Here is the call graph for this function:

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ( )

Definition at line 85 of file assLongMenuTest.php.

85 : void
86 {
87 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
88 $obj = new assLongMenu();
89 $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
90 $this->assertEquals(true, $value);
91 }

References getMethod().

+ Here is the call graph for this function:

◆ test_getAdditionalTableName_shouldReturnString()

assLongmenuTest::test_getAdditionalTableName_shouldReturnString ( )

Definition at line 67 of file assLongMenuTest.php.

67 : void
68 {
69 $instance = new assLongMenu();
70 $this->assertEquals('qpl_qst_lome', $instance->getAdditionalTableName());
71 }

◆ test_getAnswerTableName_shouldReturnString()

assLongmenuTest::test_getAnswerTableName_shouldReturnString ( )

Definition at line 79 of file assLongMenuTest.php.

79 : void
80 {
81 $instance = new assLongMenu();
82 $this->assertEquals('qpl_a_lome', $instance->getAnswerTableName());
83 }

◆ test_getMaximumPoints_shouldBeFour()

assLongmenuTest::test_getMaximumPoints_shouldBeFour ( )

Definition at line 101 of file assLongMenuTest.php.

101 : void
102 {
103 $obj = new assLongMenu();
104 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2', 2 => '1'),
105 1 => array( 0 => array(0 => 'answer'),1 => '2', 2 => '1')));
106 $value = $obj->getMaximumPoints();
107 $this->assertEquals(4, $value);
108 }

◆ test_getMaximumPoints_shouldBeFourPointFive()

assLongmenuTest::test_getMaximumPoints_shouldBeFourPointFive ( )

Definition at line 110 of file assLongMenuTest.php.

110 : void
111 {
112 $obj = new assLongMenu();
113 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
114 1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
115 $value = $obj->getMaximumPoints();
116 $this->assertEquals(4.5, $value);
117 }

◆ test_getQuestionType_shouldReturnString()

assLongmenuTest::test_getQuestionType_shouldReturnString ( )

Definition at line 73 of file assLongMenuTest.php.

73 : void
74 {
75 $instance = new assLongMenu();
76 $this->assertEquals('assLongMenu', $instance->getQuestionType());
77 }

◆ test_getSolutionSubmit_shouldReturnSolution()

assLongmenuTest::test_getSolutionSubmit_shouldReturnSolution ( )

Definition at line 210 of file assLongMenuTest.php.

210 : void
211 {
212 $obj = new assLongMenu();
213 $array = array( 0 => 'squirrel', 1 => 'icebear');
214 $_POST['answer'] = $array;
215 $this->assertEquals($obj->getSolutionSubmit(), $array);
216 }

◆ test_instantiateObject_shouldReturnInstance()

assLongmenuTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 61 of file assLongMenuTest.php.

61 : void
62 {
63 $instance = new assLongMenu();
64 $this->assertInstanceOf('assLongMenu', $instance);
65 }

◆ test_isComplete_shouldBeFalse()

assLongmenuTest::test_isComplete_shouldBeFalse ( )

Definition at line 119 of file assLongMenuTest.php.

119 : void
120 {
121 $obj = new assLongMenu();
122 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
123 1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
124 $obj->setAnswers(array(array(1,2,3,4)));
125 $this->assertEquals($obj->isComplete(), false);
126 }

◆ test_isShuffleAnswersEnabled_shouldReturnFalse()

assLongmenuTest::test_isShuffleAnswersEnabled_shouldReturnFalse ( )

Definition at line 241 of file assLongMenuTest.php.

241 : void
242 {
243 $obj = new assLongMenu();
244 $this->assertEquals(false, $obj->isShuffleAnswersEnabled());
245 $this->assertNotEquals(true, $obj->isShuffleAnswersEnabled());
246 }

◆ test_setAnswerType_shouldReturnGetAnswerType()

assLongmenuTest::test_setAnswerType_shouldReturnGetAnswerType ( )

Definition at line 218 of file assLongMenuTest.php.

218 : void
219 {
220 $obj = new assLongMenu();
221 $obj->setAnswerType(0);
222 $this->assertEquals(0, $obj->getAnswerType());
223 }

◆ test_setJsonStructure_shouldReturnGetJsonStructure()

assLongmenuTest::test_setJsonStructure_shouldReturnGetJsonStructure ( )

Definition at line 234 of file assLongMenuTest.php.

234 : void
235 {
236 $obj = new assLongMenu();
237 $obj->setJsonStructure(json_encode(array(1 => 'bla')));
238 $this->assertEquals('{"1":"bla"}', $obj->getJsonStructure());
239 }

Field Documentation

◆ $backupGlobals

assLongmenuTest::$backupGlobals = false
protected

Definition at line 27 of file assLongMenuTest.php.


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