ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assSingleChoiceTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
14 {
15  protected $backupGlobals = false;
16 
17  protected function setUp()
18  {
19  require_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
20  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
21  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
22  ilUnitUtil::performInitialisation();
23  } else {
24  chdir(dirname(__FILE__));
25  chdir('../../../');
26  }
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  }
29 
36  /*public static function createSampleQuestion($obj_id = null)
37  {
38  $obj_id = ($obj_id) ? $obj_id : 99999999;
39  include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
40  $sc = new assSingleChoice('unit test single choice question', 'unit test single choice question comment', 'Helmut Schottmüller', -1, '<p>is a <strong>unit test</strong> required?</p>');
41  $sc->addAnswer(
42  'Yes',
43  1,
44  0,
45  1
46  );
47  $sc->addAnswer(
48  'No',
49  -1,
50  0,
51  2
52  );
53  $sc->setObjId($obj_id);
54  $sc->saveToDb();
55  return $sc->getId();
56  }*/
57 
63  /*public function t_e_stCreation()
64  {
65  global $DIC;
66  $ilDB = $DIC['ilDB'];
67 
68  include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
69  $insert_id = ilassSingleChoiceTest::createSampleQuestion();
70  $this->assertGreaterThan(0, $insert_id);
71  if ($insert_id > 0)
72  {
73  $sc = new assSingleChoice();
74  $sc->loadFromDb($insert_id);
75  $this->assertEquals($sc->getPoints(),1);
76  $this->assertEquals($sc->getTitle(),"unit test single choice question");
77  $this->assertEquals($sc->getComment(),"unit test single choice question comment");
78  $this->assertEquals($sc->getAuthor(),"Helmut Schottmüller");
79  $this->assertEquals($sc->getQuestion(),"<p>is a <strong>unit test</strong> required?</p>");
80  $this->assertEquals(count($sc->getAnswers()), 2);
81  $result = $sc->delete($insert_id);
82  $this->assertEquals($result,true);
83  }
84  }
85 */
87  {
88  $obj = new assSingleChoice();
89  $this->assertEquals(false, $obj->isComplete());
90  $obj->setTitle('Tilte');
91  $obj->setAuthor('Me or another');
92  $obj->setQuestion('My great Question.');
93  $obj->addAnswer('Super simple single Choice', 1);
94 
95  $this->assertEquals(true, $obj->isComplete());
96  }
97 
99  {
100  $obj = new assSingleChoice();
101  $this->assertEquals('thumb.', $obj->getThumbPrefix());
102  }
103 
105  {
106  $obj = new assSingleChoice();
107  $obj->setOutputType(0);
108  $this->assertEquals(0, $obj->getOutputType());
109  }
110 
112  {
113  $obj = new assSingleChoice();
114  $this->assertEquals(0, $obj->getAnswerCount());
115  $obj->addAnswer('1', 1, 0);
116  $obj->addAnswer('1', 1, 1);
117  $this->assertEquals(2, $obj->getAnswerCount());
118  $obj->deleteAnswer(0);
119  $this->assertEquals(1, $obj->getAnswerCount());
120  }
121 
123  {
124  $obj = new assSingleChoice();
125  $obj->addAnswer('1', 1, 0);
126  $obj->addAnswer('1', 1, 1);
127  $this->assertEquals(2, $obj->getAnswerCount());
128  $obj->flushAnswers();
129  $this->assertEquals(0, $obj->getAnswerCount());
130  }
131 
133  {
134  $obj = new assSingleChoice();
135  $this->assertEquals('assSingleChoice', $obj->getQuestionType());
136  }
137 
139  {
140  $obj = new assSingleChoice();
141  $this->assertEquals('qpl_qst_sc', $obj->getAdditionalTableName());
142  }
143 
145  {
146  $obj = new assSingleChoice();
147  $this->assertEquals('qpl_a_sc', $obj->getAnswerTableName());
148  }
149 }
test_isComplete_shouldReturnTrue()
Create a sample question and save it to the database.
Class for single choice questions.
test_getAdditionalTableName_shouldReturnAdditionalTableName()
Unit tests for single choice questions.