34 $method = $class->getMethod($name);
35 $method->setAccessible(
true);
39 protected function setUp(): void
41 chdir(dirname(__FILE__));
46 $ilCtrl_mock = $this->createMock(
'ilCtrl');
47 $ilCtrl_mock->expects($this->any())->method(
'saveParameter');
48 $ilCtrl_mock->expects($this->any())->method(
'saveParameterByClass');
51 $lng_mock = $this->createMock(
'ilLanguage', array(
'txt'), array(),
'',
false);
63 $this->assertInstanceOf(
'assLongMenu', $instance);
69 $this->assertEquals(
'qpl_qst_lome', $instance->getAdditionalTableName());
75 $this->assertEquals(
'assLongMenu', $instance->getQuestionType());
81 $this->assertEquals(
'qpl_a_lome', $instance->getAnswerTableName());
86 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
88 $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
89 $this->assertEquals(
true, $value);
94 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
96 $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
97 $this->assertEquals(
false, $value);
103 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2', 2 =>
'1'),
104 1 => array( 0 => array(0 =>
'answer'),1 =>
'2', 2 =>
'1')));
105 $value = $obj->getMaximumPoints();
106 $this->assertEquals(4, $value);
112 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1'),
113 1 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1')));
114 $value = $obj->getMaximumPoints();
115 $this->assertEquals(4.5, $value);
121 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1'),
122 1 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1')));
123 $obj->setAnswers(array(array(1,2,3,4)));
124 $this->assertEquals($obj->isComplete(),
false);
144 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
150 $obj->setAnswers(array(array(1,2,3,4)));
151 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
157 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1'),
158 1 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1')));
159 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
164 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1'),
165 1 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1')));
166 $obj->setAnswers(array(array(
'answer')));
167 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
172 $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 =>
'answer'),1 =>
'2.25', 2 =>
'1')));
173 $obj->setAnswers(array(array(1)));
174 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
180 $obj->setCorrectAnswers(array( 0 => array( 0 => array(),1 =>
'2.25', 2 =>
'1')));
181 $obj->setAnswers(array(array(
'answer')));
182 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
188 $obj->setCorrectAnswers(array( 0 => array( 0 => array())));
189 $obj->setAnswers(array(array(
'answer')));
190 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
196 $obj->setCorrectAnswers(array( 0 => array( 0 => array(
'answer'),1 => 0, 2 =>
'1')));
197 $obj->setAnswers(array(array(
'answer')));
198 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
204 $obj->setCorrectAnswers(array( 0 => array( 0 => array(
'answer'),1 => 1, 2 =>
'1')));
205 $obj->setAnswers(array(array(
'answer')));
206 $this->assertEquals($obj->checkQuestionCustomPart(),
true);
212 $array = array( 0 =>
'squirrel', 1 =>
'icebear');
213 $_POST[
'answer'] = $array;
214 $this->assertEquals($obj->getSolutionSubmit(), $array);
220 $obj->setAnswerType([]);
221 $this->assertEquals([], $obj->getAnswerType());
236 $obj->setJsonStructure(json_encode(array(1 =>
'bla')));
237 $this->assertEquals(
'{"1":"bla"}', $obj->getJsonStructure());
243 $this->assertEquals(
false, $obj->isShuffleAnswersEnabled());
244 $this->assertNotEquals(
true, $obj->isShuffleAnswersEnabled());
setGlobalVariable(string $name, $value)