ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assKprimChoiceTest.php
Go to the documentation of this file.
1 <?php
10 {
11  protected $backupGlobals = false;
12 
13  protected function setUp()
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 
52  {
53  $obj = new assKprimChoice();
54  $this->assertEquals(false, $obj->isComplete());
55  $obj->setTitle('Tilte');
56  $obj->setAuthor('Me or another');
57  $obj->setQuestion('My great Question.');
58  $this->assertEquals(false, $obj->isComplete());
59  $obj->setPoints(1);
60  $this->assertEquals(true, $obj->isComplete());
61  }
62 
64  {
65  $obj = new assKprimChoice();
66  $this->assertEquals(false, $obj->isComplete());
67  $obj->setTitle('Tilte');
68  $obj->setAuthor('Me or another');
69  $obj->setQuestion('My great Question.');
70  $obj->setPoints(1);
71  $ans = new ilAssKprimChoiceAnswer();
72  $obj->addAnswer($ans);
73  $this->assertEquals(false, $obj->isComplete());
74  $ans->setCorrectness(true);
75  $obj->addAnswer($ans);
76  $this->assertEquals(false, $obj->isComplete());
77  $ans->setAnswertext('Text');
78  $obj->addAnswer($ans);
79  $this->assertEquals(true, $obj->isComplete());
80  }
81 
83  {
84  $obj = new assKprimChoice();
85  $this->assertEquals(false, $obj->isValidOptionLabel('not valid'));
86  $this->assertEquals(true, $obj->isValidOptionLabel($obj::OPTION_LABEL_RIGHT_WRONG));
87  }
88 
90  {
91  $obj = new assKprimChoice();
92  $this->assertEquals(true, $obj->isObligationPossible(1));
93  }
94 
96  {
97  $obj = new assKprimChoice();
98  $ans = new ilAssKprimChoiceAnswer();
99  $ans->setCorrectness(true);
100  $ans->setAnswertext('Text');
101  $obj->addAnswer($ans);
102  $this->assertInstanceOf('ilAssKprimChoiceAnswer', $obj->getAnswer(0));
103  $this->assertEquals(null, $obj->getAnswer(1));
104  }
105 
107  {
108  $obj = new assKprimChoice();
109  $this->assertEquals(false, $obj->isValidAnswerType('not valid'));
110  $this->assertEquals(true, $obj->isValidAnswerType($obj::ANSWER_TYPE_SINGLE_LINE));
111  }
112 }
test_getAnswerTableName_shouldReturnAnswerTableName()
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
test_getAdditionalTableName_shouldReturnAdditionalTableName()