ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir( dirname( __FILE__ ) );
25  chdir('../../../');
26  }
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  }
29 
31  {
32  $instance = new assKprimChoice();
33  $this->assertInstanceOf('assKprimChoice', $instance);
34  }
35 
37  {
38  $obj = new assKprimChoice();
39  $this->assertEquals('assKprimChoice', $obj->getQuestionType());
40  }
41 
43  {
44  $obj = new assKprimChoice();
45  $this->assertEquals('qpl_qst_kprim', $obj->getAdditionalTableName());
46  }
47 
49  {
50  $obj = new assKprimChoice();
51  $this->assertEquals('qpl_a_kprim', $obj->getAnswerTableName());
52  }
53 
55  {
56  $obj = new assKprimChoice();
57  $this->assertEquals(false, $obj->isComplete());
58  $obj->setTitle('Tilte');
59  $obj->setAuthor('Me or another');
60  $obj->setQuestion('My great Question.');
61  $this->assertEquals(false, $obj->isComplete());
62  $obj->setPoints(1);
63  $this->assertEquals(true, $obj->isComplete());
64  }
65 
67  {
68  $obj = new assKprimChoice();
69  $this->assertEquals(false, $obj->isComplete());
70  $obj->setTitle('Tilte');
71  $obj->setAuthor('Me or another');
72  $obj->setQuestion('My great Question.');
73  $obj->setPoints(1);
74  $ans = new ilAssKprimChoiceAnswer();
75  $obj->addAnswer($ans);
76  $this->assertEquals(false, $obj->isComplete());
77  $ans->setCorrectness(true);
78  $obj->addAnswer($ans);
79  $this->assertEquals(false, $obj->isComplete());
80  $ans->setAnswertext('Text');
81  $obj->addAnswer($ans);
82  $this->assertEquals(true, $obj->isComplete());
83  }
84 
86  {
87  $obj = new assKprimChoice();
88  $this->assertEquals(false, $obj->isValidOptionLabel('not valid'));
89  $this->assertEquals(true, $obj->isValidOptionLabel($obj::OPTION_LABEL_RIGHT_WRONG));
90  }
91 
93  {
94  $obj = new assKprimChoice();
95  $this->assertEquals(true, $obj->isObligationPossible(1));
96  }
97 
99  {
100  $obj = new assKprimChoice();
101  $ans = new ilAssKprimChoiceAnswer();
102  $ans->setCorrectness(true);
103  $ans->setAnswertext('Text');
104  $obj->addAnswer($ans);
105  $this->assertInstanceOf('ilAssKprimChoiceAnswer', $obj->getAnswer(0));
106  $this->assertEquals(null, $obj->getAnswer(1));
107  }
108 
110  {
111  $obj = new assKprimChoice();
112  $this->assertEquals(false, $obj->isValidAnswerType('not valid'));
113  $this->assertEquals(true, $obj->isValidAnswerType($obj::ANSWER_TYPE_SINGLE_LINE));
114  }
115 
116 
117 
118 }
test_getAnswerTableName_shouldReturnAnswerTableName()
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
test_getAdditionalTableName_shouldReturnAdditionalTableName()