ILIAS  release_8 Revision v8.24
assKprimChoiceTest.php
Go to the documentation of this file.
1<?php
26{
27 protected $backupGlobals = false;
28
29 protected function setUp(): void
30 {
31 parent::setUp();
32 $this->setGlobalVariable('ilias', $this->getIliasMock());
33 $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
34 }
35
37 {
38 $instance = new assKprimChoice();
39 $this->assertInstanceOf('assKprimChoice', $instance);
40 }
41
43 {
44 $obj = new assKprimChoice();
45 $this->assertEquals('assKprimChoice', $obj->getQuestionType());
46 }
47
49 {
50 $obj = new assKprimChoice();
51 $this->assertEquals('qpl_qst_kprim', $obj->getAdditionalTableName());
52 }
53
55 {
56 $obj = new assKprimChoice();
57 $this->assertEquals('qpl_a_kprim', $obj->getAnswerTableName());
58 }
59
60 /* Removed by @kergomard 17 NOV 2022, we should introduce this again
61 public function test_isCompleteWithoutAnswer_shouldReturnTrue(): void
62 {
63 $obj = new assKprimChoice();
64 $this->assertEquals(false, $obj->isComplete());
65 $obj->setTitle('Tilte');
66 $obj->setAuthor('Me or another');
67 $obj->setQuestion('My great Question.');
68 $this->assertEquals(false, $obj->isComplete());
69 $obj->setPoints(1);
70 $this->assertEquals(true, $obj->isComplete());
71 }
72
73 public function test_isCompleteWithAnswer_shouldReturnTrue(): void
74 {
75 $obj = new assKprimChoice();
76 $this->assertEquals(false, $obj->isComplete());
77 $obj->setTitle('Tilte');
78 $obj->setAuthor('Me or another');
79 $obj->setQuestion('My great Question.');
80 $obj->setPoints(1);
81 $ans = new ilAssKprimChoiceAnswer();
82 $obj->addAnswer($ans);
83 $this->assertEquals(false, $obj->isComplete());
84 $ans->setCorrectness(true);
85 $obj->addAnswer($ans);
86 $this->assertEquals(false, $obj->isComplete());
87 $ans->setAnswertext('Text');
88 $obj->addAnswer($ans);
89 $this->assertEquals(true, $obj->isComplete());
90 } */
91
93 {
94 $obj = new assKprimChoice();
95 $this->assertEquals(false, $obj->isValidOptionLabel('not valid'));
96 $this->assertEquals(true, $obj->isValidOptionLabel($obj::OPTION_LABEL_RIGHT_WRONG));
97 }
98
100 {
101 $obj = new assKprimChoice();
102 $this->assertEquals(true, $obj->isObligationPossible(1));
103 }
104
105 /* Removed by @kergomard 17 NOV 2022, we should introduce this again
106 public function test_getAnswer_shouldReturnAnswer(): void
107 {
108 $obj = new assKprimChoice();
109 $ans = new ilAssKprimChoiceAnswer();
110 $ans->setCorrectness(true);
111 $ans->setAnswertext('Text');
112 $obj->addAnswer($ans);
113 $this->assertInstanceOf('ilAssKprimChoiceAnswer', $obj->getAnswer(0));
114 $this->assertEquals(null, $obj->getAnswer(1));
115 } */
116
118 {
119 $obj = new assKprimChoice();
120 $this->assertEquals(false, $obj->isValidAnswerType('not valid'));
121 $this->assertEquals(true, $obj->isValidAnswerType($obj::ANSWER_TYPE_SINGLE_LINE));
122 }
123}
Class assBaseTestCase.
setGlobalVariable(string $name, $value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
test_getAnswerTableName_shouldReturnAnswerTableName()
test_getAdditionalTableName_shouldReturnAdditionalTableName()