ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
assLongMenuTest.php
Go to the documentation of this file.
1<?php
10{
11 protected $backupGlobals = FALSE;
12
13
14 protected static function getMethod($name) {
15 $class = new ReflectionClass('assLongMenu');
16 $method = $class->getMethod($name);
17 $method->setAccessible(true);
18 return $method;
19 }
20
21 protected function setUp()
22 {
23 $GLOBALS['DIC']['ilDB'] = 'test';
24
25 require_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
26 if (defined('ILIAS_PHPUNIT_CONTEXT'))
27 {
28 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29 ilUnitUtil::performInitialisation();
30 }
31 else
32 {
33 chdir( dirname( __FILE__ ) );
34 chdir('../../../');
35 }
36 require_once './Services/Utilities/classes/class.ilUtil.php';
37 }
38
40 {
41 $instance = new assLongMenu();
42 $this->assertInstanceOf('assLongMenu', $instance);
43 }
44
46 {
47 $instance = new assLongMenu();
48 $this->assertEquals('qpl_qst_lome', $instance->getAdditionalTableName());
49 }
50
52 {
53 $instance = new assLongMenu();
54 $this->assertEquals('assLongMenu', $instance->getQuestionType());
55 }
56
58 {
59 $instance = new assLongMenu();
60 $this->assertEquals('qpl_a_lome', $instance->getAnswerTableName());
61 }
62
64 {
65 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
66 $obj = new assLongMenu();
67 $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
68 $this->assertEquals(true, $value);
69 }
70
72 {
73 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
74 $obj = new assLongMenu();
75 $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
76 $this->assertEquals(false, $value);
77 }
78
80 {
81 $obj = new assLongMenu();
82 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1'),
83 1 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1')));
84 $value = $obj->getMaximumPoints();
85 $this->assertEquals(4, $value);
86 }
87
89 {
90 $obj = new assLongMenu();
91 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
92 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
93 $value = $obj->getMaximumPoints();
94 $this->assertEquals(4.5, $value);
95 }
96
98 {
99 $obj = new assLongMenu();
100 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
101 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
102 $obj->setAnswers(array(array(1,2,3,4)));
103 $this->assertEquals($obj->isComplete(), false);
104 }
105
107 {
108 $obj = new assLongMenu();
109 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
110 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
111 $obj->setAnswers(array(array(1,2,3,4)));
112 $obj->setPoints(4.5);
113 $obj->setTitle('LongMenu Title');
114 $obj->setQuestion('LongMenu Question');
115 $this->assertEquals($obj->isComplete(), true);
116 }
117
119 {
120 $obj = new assLongMenu();
121 $this->assertEquals($obj->checkQuestionCustomPart(), false);
122 }
123
125 {
126 $obj = new assLongMenu();
127 $obj->setAnswers(array(array(1,2,3,4)));
128 $this->assertEquals($obj->checkQuestionCustomPart(), false);
129 }
130
132 {
133 $obj = new assLongMenu();
134 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
135 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
136 $this->assertEquals($obj->checkQuestionCustomPart(), false);
137 }
139 {
140 $obj = new assLongMenu();
141 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
142 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
143 $obj->setAnswers(array(array('answer')));
144 $this->assertEquals($obj->checkQuestionCustomPart(), false);
145 }
147 {
148 $obj = new assLongMenu();
149 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
150 $obj->setAnswers(array(array(1)));
151 $this->assertEquals($obj->checkQuestionCustomPart(), false);
152 }
153
155 {
156 $obj = new assLongMenu();
157 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (),1 => '2.25', 2 => '1')));
158 $obj->setAnswers(array(array('answer')));
159 $this->assertEquals($obj->checkQuestionCustomPart(), false);
160 }
161
163 {
164 $obj = new assLongMenu();
165 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ())));
166 $obj->setAnswers(array(array('answer')));
167 $this->assertEquals($obj->checkQuestionCustomPart(), false);
168 }
169
171 {
172 $obj = new assLongMenu();
173 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 0, 2 => '1')));
174 $obj->setAnswers(array(array('answer')));
175 $this->assertEquals($obj->checkQuestionCustomPart(), false);
176 }
177
179 {
180 $obj = new assLongMenu();
181 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 1, 2 => '1')));
182 $obj->setAnswers(array(array('answer')));
183 $this->assertEquals($obj->checkQuestionCustomPart(), true);
184 }
185
187 {
188 $obj = new assLongMenu();
189 $array = array( 0 => 'squirrel', 1 => 'icebear');
190 $_POST['answer'] = $array;
191 $this->assertEquals($obj->getSolutionSubmit(), $array);
192 }
193
195 {
196 $obj = new assLongMenu();
197 $obj->setAnswerType(0);
198 $this->assertEquals(0, $obj->getAnswerType());
199 }
201 {
202 $obj = new assLongMenu();
203 $this->assertEquals('', $obj->getLongMenuTextValue());
204 $obj->setLongMenuTextValue('dummy text');
205 $this->assertEquals('dummy text', $obj->getLongMenuTextValue());
206 }
207
209 {
210 $obj = new assLongMenu();
211 $obj->setJsonStructure(json_encode(array(1 => 'bla')));
212 $this->assertEquals('{"1":"bla"}', $obj->getJsonStructure());
213 }
214
216 {
217 $obj = new assLongMenu();
218 $this->assertEquals(false, $obj->isShuffleAnswersEnabled());
219 $this->assertNotEquals(true, $obj->isShuffleAnswersEnabled());
220 }
221
222}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
test_getAdditionalTableName_shouldReturnString()
test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue()
test_getMaximumPoints_shouldBeFourPointFive()
test_getAnswerTableName_shouldReturnString()
static getMethod($name)
test_isShuffleAnswersEnabled_shouldReturnFalse()
test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()
test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()
test_setAnswerType_shouldReturnGetAnswerType()
test_getSolutionSubmit_shouldReturnSolution()
test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()
test_instantiateObject_shouldReturnInstance()
test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()
test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()
test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()
test_getMaximumPoints_shouldBeFour()
test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()
test_checkQuestionCustomPart_shouldBeTrue()
test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()
test_getQuestionType_shouldReturnString()
test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()
test_setJsonStructure_shouldReturnGetJsonStructure()
test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27