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');
50 $lng_mock = $this->createMock(
'ilLanguage', [
'txt'], [],
'',
false);
60 $this->assertInstanceOf(assLongMenu::class, $instance);
66 $this->assertEquals(
'qpl_qst_lome', $instance->getAdditionalTableName());
72 $this->assertEquals(
'assLongMenu', $instance->getQuestionType());
78 $this->assertEquals(
'qpl_a_lome', $instance->getAnswerTableName());
83 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
85 $value = $method->invokeArgs($obj, [[[5],1,1], [1,2,3,4]]);
86 $this->assertEquals(
true, $value);
91 $method = self::getMethod(
'correctAnswerDoesNotExistInAnswerOptions');
93 $value = $method->invokeArgs($obj, [[[1],1,1], [1,2,3,4]]);
94 $this->assertEquals(
false, $value);
100 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1']]);
101 $value = $obj->getMaximumPoints();
102 $this->assertEquals(4, $value);
108 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
109 $value = $obj->getMaximumPoints();
110 $this->assertEquals(4.5, $value);
116 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
117 $obj->setAnswers([[1,2,3,4]]);
118 $this->assertEquals($obj->isComplete(),
false);
137 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
143 $obj->setAnswers([[1,2,3,4]]);
144 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
150 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
151 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
156 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
157 $obj->setAnswers([[
'answer']]);
158 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
163 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
164 $obj->setAnswers([[1]]);
165 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
171 $obj->setCorrectAnswers([0 => [0 => [], 1 =>
'2.25', 2 =>
'1']]);
172 $obj->setAnswers([[
'answer']]);
173 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
179 $obj->setCorrectAnswers([0 => [0 => []]]);
180 $obj->setAnswers([[
'answer']]);
181 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
187 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 0, 2 =>
'1']]);
188 $obj->setAnswers([[
'answer']]);
189 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
195 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 1, 2 =>
'1']]);
196 $obj->setAnswers([[
'answer']]);
197 $this->assertEquals($obj->checkQuestionCustomPart(),
true);
203 $obj->setAnswerType([]);
204 $this->assertEquals([], $obj->getAnswerType());
219 $this->assertEquals(
false, $obj->isShuffleAnswersEnabled());
220 $this->assertNotEquals(
true, $obj->isShuffleAnswersEnabled());
setGlobalVariable(string $name, mixed $value)