34 $method = $class->getMethod($name);
35 $method->setAccessible(
true);
39 protected function setUp(): void
41 chdir(__DIR__ .
'/../../../../');
45 $ilCtrl_mock = $this->createMock(
'ilCtrl');
46 $ilCtrl_mock->expects($this->any())->method(
'saveParameter');
47 $ilCtrl_mock->expects($this->any())->method(
'saveParameterByClass');
48 $this->setGlobalVariable(
'ilCtrl', $ilCtrl_mock);
50 $lng_mock = $this->createMock(
'ilLanguage', [
'txt'], [],
'',
false);
52 $this->setGlobalVariable(
'lng', $lng_mock);
54 $this->setGlobalVariable(
'ilias', $this->getIliasMock());
55 $this->setGlobalVariable(
'ilDB', $this->getDatabaseMock());
61 $this->assertInstanceOf(assLongMenu::class, $instance);
67 $this->assertEquals(
'qpl_qst_lome', $instance->getAdditionalTableName());
73 $this->assertEquals(
'assLongMenu', $instance->getQuestionType());
79 $this->assertEquals(
'qpl_a_lome', $instance->getAnswerTableName());
84 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
86 $value = $method->invokeArgs($obj, [[[5],1,1], [1,2,3,4]]);
87 $this->assertEquals(
true, $value);
92 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
94 $value = $method->invokeArgs($obj, [[[1],1,1], [1,2,3,4]]);
95 $this->assertEquals(
false, $value);
101 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1']]);
102 $value = $obj->getMaximumPoints();
103 $this->assertEquals(4, $value);
109 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
110 $value = $obj->getMaximumPoints();
111 $this->assertEquals(4.5, $value);
117 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
118 $obj->setAnswers([[1,2,3,4]]);
119 $this->assertEquals($obj->isComplete(),
false);
138 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
144 $obj->setAnswers([[1,2,3,4]]);
145 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
151 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
152 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
157 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
158 $obj->setAnswers([[
'answer']]);
159 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
164 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
165 $obj->setAnswers([[1]]);
166 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
172 $obj->setCorrectAnswers([0 => [0 => [], 1 =>
'2.25', 2 =>
'1']]);
173 $obj->setAnswers([[
'answer']]);
174 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
180 $obj->setCorrectAnswers([0 => [0 => []]]);
181 $obj->setAnswers([[
'answer']]);
182 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
188 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 0, 2 =>
'1']]);
189 $obj->setAnswers([[
'answer']]);
190 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
196 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 1, 2 =>
'1']]);
197 $obj->setAnswers([[
'answer']]);
198 $this->assertEquals($obj->checkQuestionCustomPart(),
true);
204 $obj->setAnswerType([]);
205 $this->assertEquals([], $obj->getAnswerType());
220 $this->assertEquals(
false, $obj->isShuffleAnswersEnabled());
221 $this->assertNotEquals(
true, $obj->isShuffleAnswersEnabled());