ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
assKprimChoiceTest.php
Go to the documentation of this file.
1<?php
10{
11 protected $backupGlobals = false;
12
13 protected function setUp() : void
14 {
15 require_once './Modules/TestQuestionPool/classes/class.assKprimChoice.php';
16 require_once './Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
17 if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19 ilUnitUtil::performInitialisation();
20 } else {
21 chdir(dirname(__FILE__));
22 chdir('../../../');
23 }
24 require_once './Services/Utilities/classes/class.ilUtil.php';
25 }
26
28 {
29 $instance = new assKprimChoice();
30 $this->assertInstanceOf('assKprimChoice', $instance);
31 }
32
34 {
35 $obj = new assKprimChoice();
36 $this->assertEquals('assKprimChoice', $obj->getQuestionType());
37 }
38
40 {
41 $obj = new assKprimChoice();
42 $this->assertEquals('qpl_qst_kprim', $obj->getAdditionalTableName());
43 }
44
46 {
47 $obj = new assKprimChoice();
48 $this->assertEquals('qpl_a_kprim', $obj->getAnswerTableName());
49 }
50
51 /* Removed by @kergomard 17 NOV 2022, we should introduce this again
52 public function test_isCompleteWithoutAnswer_shouldReturnTrue()
53 {
54 $obj = new assKprimChoice();
55 $this->assertEquals(false, $obj->isComplete());
56 $obj->setTitle('Tilte');
57 $obj->setAuthor('Me or another');
58 $obj->setQuestion('My great Question.');
59 $this->assertEquals(false, $obj->isComplete());
60 $obj->setPoints(1);
61 $this->assertEquals(true, $obj->isComplete());
62 }
63
64 public function test_isCompleteWithAnswer_shouldReturnTrue()
65 {
66 $obj = new assKprimChoice();
67 $this->assertEquals(false, $obj->isComplete());
68 $obj->setTitle('Tilte');
69 $obj->setAuthor('Me or another');
70 $obj->setQuestion('My great Question.');
71 $obj->setPoints(1);
72 $ans = new ilAssKprimChoiceAnswer();
73 $obj->addAnswer($ans);
74 $this->assertEquals(false, $obj->isComplete());
75 $ans->setCorrectness(true);
76 $obj->addAnswer($ans);
77 $this->assertEquals(false, $obj->isComplete());
78 $ans->setAnswertext('Text');
79 $obj->addAnswer($ans);
80 $this->assertEquals(true, $obj->isComplete());
81 }*/
82
84 {
85 $obj = new assKprimChoice();
86 $this->assertEquals(false, $obj->isValidOptionLabel('not valid'));
87 $this->assertEquals(true, $obj->isValidOptionLabel($obj::OPTION_LABEL_RIGHT_WRONG));
88 }
89
91 {
92 $obj = new assKprimChoice();
93 $this->assertEquals(true, $obj->isObligationPossible(1));
94 }
95
96 /* Removed by @kergomard 17 NOV 2022, we should introduce this again
97 public function test_getAnswer_shouldReturnAnswer()
98 {
99 $obj = new assKprimChoice();
100 $ans = new ilAssKprimChoiceAnswer();
101 $ans->setCorrectness(true);
102 $ans->setAnswertext('Text');
103 $obj->addAnswer($ans);
104 $this->assertInstanceOf('ilAssKprimChoiceAnswer', $obj->getAnswer(0));
105 $this->assertEquals(null, $obj->getAnswer(1));
106 } */
107
109 {
110 $obj = new assKprimChoice();
111 $this->assertEquals(false, $obj->isValidAnswerType('not valid'));
112 $this->assertEquals(true, $obj->isValidAnswerType($obj::ANSWER_TYPE_SINGLE_LINE));
113 }
114}
An exception for terminatinating execution or to throw for unit testing.
Class assBaseTestCase.
test_getAnswerTableName_shouldReturnAnswerTableName()
test_getAdditionalTableName_shouldReturnAdditionalTableName()