ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
assLongMenuTest.php
Go to the documentation of this file.
1<?php
10{
11 protected $backupGlobals = FALSE;
12
13 protected static function getMethod($name) {
14 $class = new ReflectionClass('assLongMenu');
15 $method = $class->getMethod($name);
16 $method->setAccessible(true);
17 return $method;
18 }
19
20 protected function setUp()
21 {
22 require_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
23 if (defined('ILIAS_PHPUNIT_CONTEXT'))
24 {
25 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
27 }
28 else
29 {
30 chdir( dirname( __FILE__ ) );
31 chdir('../../../');
32 }
33 require_once './Services/Utilities/classes/class.ilUtil.php';
34 }
35
37 {
38 $instance = new assLongMenu();
39 $this->assertInstanceOf('assLongMenu', $instance);
40 }
41
43 {
44 $instance = new assLongMenu();
45 $this->assertEquals('qpl_qst_lome', $instance->getAdditionalTableName());
46 }
47
49 {
50 $instance = new assLongMenu();
51 $this->assertEquals('assLongMenu', $instance->getQuestionType());
52 }
53
55 {
56 $instance = new assLongMenu();
57 $this->assertEquals('qpl_a_lome', $instance->getAnswerTableName());
58 }
59
61 {
62 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
63 $obj = new assLongMenu();
64 $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
65 $this->assertEquals(true, $value);
66 }
67
69 {
70 $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
71 $obj = new assLongMenu();
72 $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
73 $this->assertEquals(false, $value);
74 }
75
77 {
78 $obj = new assLongMenu();
79 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1'),
80 1 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1')));
81 $value = $obj->getMaximumPoints();
82 $this->assertEquals(4, $value);
83 }
84
86 {
87 $obj = new assLongMenu();
88 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
89 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
90 $value = $obj->getMaximumPoints();
91 $this->assertEquals(4.5, $value);
92 }
93
95 {
96 $obj = new assLongMenu();
97 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
98 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
99 $obj->setAnswers(array(array(1,2,3,4)));
100 $this->assertEquals($obj->isComplete(), false);
101 }
102
104 {
105 $obj = new assLongMenu();
106 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
107 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
108 $obj->setAnswers(array(array(1,2,3,4)));
109 $obj->setPoints(4.5);
110 $obj->setTitle('LongMenu Title');
111 $obj->setQuestion('LongMenu Question');
112 $this->assertEquals($obj->isComplete(), true);
113 }
114
116 {
117 $obj = new assLongMenu();
118 $this->assertEquals($obj->checkQuestionCustomPart(), false);
119 }
120
122 {
123 $obj = new assLongMenu();
124 $obj->setAnswers(array(array(1,2,3,4)));
125 $this->assertEquals($obj->checkQuestionCustomPart(), false);
126 }
127
129 {
130 $obj = new assLongMenu();
131 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
132 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
133 $this->assertEquals($obj->checkQuestionCustomPart(), false);
134 }
136 {
137 $obj = new assLongMenu();
138 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
139 1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
140 $obj->setAnswers(array(array('answer')));
141 $this->assertEquals($obj->checkQuestionCustomPart(), false);
142 }
144 {
145 $obj = new assLongMenu();
146 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
147 $obj->setAnswers(array(array(1)));
148 $this->assertEquals($obj->checkQuestionCustomPart(), false);
149 }
150
152 {
153 $obj = new assLongMenu();
154 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (),1 => '2.25', 2 => '1')));
155 $obj->setAnswers(array(array('answer')));
156 $this->assertEquals($obj->checkQuestionCustomPart(), false);
157 }
158
160 {
161 $obj = new assLongMenu();
162 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ())));
163 $obj->setAnswers(array(array('answer')));
164 $this->assertEquals($obj->checkQuestionCustomPart(), false);
165 }
166
168 {
169 $obj = new assLongMenu();
170 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 0, 2 => '1')));
171 $obj->setAnswers(array(array('answer')));
172 $this->assertEquals($obj->checkQuestionCustomPart(), false);
173 }
174
176 {
177 $obj = new assLongMenu();
178 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 1, 2 => '1')));
179 $obj->setAnswers(array(array('answer')));
180 $this->assertEquals($obj->checkQuestionCustomPart(), true);
181 }
182
184 {
185 $obj = new assLongMenu();
186 $array = array( 0 => 'squirrel', 1 => 'icebear');
187 $_POST['answer'] = $array;
188 $this->assertEquals($obj->getSolutionSubmit(), $array);
189 }
190
192 {
193 $obj = new assLongMenu();
194 $obj->setAnswerType(0);
195 $this->assertEquals(0, $obj->getAnswerType());
196 }
198 {
199 $obj = new assLongMenu();
200 $this->assertEquals('', $obj->getLongMenuTextValue());
201 $obj->setLongMenuTextValue('dummy text');
202 $this->assertEquals('dummy text', $obj->getLongMenuTextValue());
203 }
204
206 {
207 $obj = new assLongMenu();
208 $obj->setJsonStructure(json_encode(array(1 => 'bla')));
209 $this->assertEquals('{"1":"bla"}', $obj->getJsonStructure());
210 }
211
213 {
214 $obj = new assLongMenu();
215 $this->assertEquals(false, $obj->isShuffleAnswersEnabled());
216 $this->assertNotEquals(true, $obj->isShuffleAnswersEnabled());
217 }
218
219}
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()
$_POST['username']
Definition: cron.php:12