31 protected static function getMethod($name): ReflectionMethod
33 $class =
new ReflectionClass(assLongMenu::class);
34 $method = $class->getMethod($name);
38 protected function setUp(): void
40 chdir(__DIR__ .
'/../../../../');
44 $ilCtrl_mock = $this->createMock(
'ilCtrl');
45 $ilCtrl_mock->expects($this->any())->method(
'saveParameter');
46 $ilCtrl_mock->expects($this->any())->method(
'saveParameterByClass');
49 $lng_mock = $this->createMock(
'ilLanguage', [
'txt'], [],
'',
false);
59 $this->assertInstanceOf(assLongMenu::class, $instance);
65 $this->assertEquals(
'qpl_qst_lome', $instance->getAdditionalTableName());
71 $this->assertEquals(
'assLongMenu', $instance->getQuestionType());
77 $this->assertEquals(
'qpl_a_lome', $instance->getAnswerTableName());
84 $value = $method->invokeArgs($obj, [[[5],1,1], [1,2,3,4]]);
85 $this->assertEquals(
true, $value);
92 $value = $method->invokeArgs($obj, [[[1],1,1], [1,2,3,4]]);
93 $this->assertEquals(
false, $value);
99 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2', 2 =>
'1']]);
100 $value = $obj->getMaximumPoints();
101 $this->assertEquals(4, $value);
107 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
108 $value = $obj->getMaximumPoints();
109 $this->assertEquals(4.5, $value);
115 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
116 $obj->setAnswers([[1,2,3,4]]);
117 $this->assertEquals($obj->isComplete(),
false);
136 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
142 $obj->setAnswers([[1,2,3,4]]);
143 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
149 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
150 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
155 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1'], 1 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
156 $obj->setAnswers([[
'answer']]);
157 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
162 $obj->setCorrectAnswers([0 => [0 => [0 =>
'answer'], 1 =>
'2.25', 2 =>
'1']]);
163 $obj->setAnswers([[1]]);
164 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
170 $obj->setCorrectAnswers([0 => [0 => [], 1 =>
'2.25', 2 =>
'1']]);
171 $obj->setAnswers([[
'answer']]);
172 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
178 $obj->setCorrectAnswers([0 => [0 => []]]);
179 $obj->setAnswers([[
'answer']]);
180 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
186 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 0, 2 =>
'1']]);
187 $obj->setAnswers([[
'answer']]);
188 $this->assertEquals($obj->checkQuestionCustomPart(),
false);
194 $obj->setCorrectAnswers([0 => [0 => [
'answer'], 1 => 1, 2 =>
'1']]);
195 $obj->setAnswers([[
'answer']]);
196 $this->assertEquals($obj->checkQuestionCustomPart(),
true);
202 $obj->setAnswerType([]);
203 $this->assertEquals([], $obj->getAnswerType());
218 $this->assertEquals(
false, $obj->isShuffleAnswersEnabled());
219 $this->assertNotEquals(
true, $obj->isShuffleAnswersEnabled());
setGlobalVariable(string $name, mixed $value)