14 $class =
new ReflectionClass(
'assLongMenu');
15 $method = $class->getMethod($name);
16 $method->setAccessible(
true);
22 require_once
'./Modules/TestQuestionPool/classes/class.assLongMenu.php';
23 if (defined(
'ILIAS_PHPUNIT_CONTEXT'))
25 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
30 chdir( dirname( __FILE__ ) );
33 require_once
'./Services/Utilities/classes/class.ilUtil.php';
39 $this->assertInstanceOf(
'assLongMenu', $instance);
45 $this->assertEquals(
'qpl_qst_lome', $instance->getAdditionalTableName());
51 $this->assertEquals(
'assLongMenu', $instance->getQuestionType());
57 $this->assertEquals(
'qpl_a_lome', $instance->getAnswerTableName());
62 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
64 $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
65 $this->assertEquals(
true, $value);
70 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
72 $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
73 $this->assertEquals(
false, $value);
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);
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);
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);
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);
118 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
124 $obj->setAnswers(array(array(1,2,3,4)));
125 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
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);
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);
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);
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);
162 $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ())));
163 $obj->setAnswers(array(array(
'answer')));
164 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
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);
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);
186 $array = array( 0 =>
'squirrel', 1 =>
'icebear');
187 $_POST[
'answer'] = $array;
188 $this->assertEquals($obj->getSolutionSubmit(), $array);
194 $obj->setAnswerType(0);
195 $this->assertEquals(0, $obj->getAnswerType());
200 $this->assertEquals(
'', $obj->getLongMenuTextValue());
201 $obj->setLongMenuTextValue(
'dummy text');
202 $this->assertEquals(
'dummy text', $obj->getLongMenuTextValue());
208 $obj->setJsonStructure(json_encode(array(1 =>
'bla')));
209 $this->assertEquals(
'{"1":"bla"}', $obj->getJsonStructure());
215 $this->assertEquals(
false, $obj->isShuffleAnswersEnabled());
216 $this->assertNotEquals(
true, $obj->isShuffleAnswersEnabled());