ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
66 
67  include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
68  $insert_id = ilassSingleChoiceTest::createSampleQuestion();
69  $this->assertGreaterThan(0, $insert_id);
70  if ($insert_id > 0)
71  {
72  $sc = new assSingleChoice();
73  $sc->loadFromDb($insert_id);
74  $this->assertEquals($sc->getPoints(),1);
75  $this->assertEquals($sc->getTitle(),"unit test single choice question");
76  $this->assertEquals($sc->getComment(),"unit test single choice question comment");
77  $this->assertEquals($sc->getAuthor(),"Helmut Schottmüller");
78  $this->assertEquals($sc->getQuestion(),"<p>is a <strong>unit test</strong> required?</p>");
79  $this->assertEquals(count($sc->getAnswers()), 2);
80  $result = $sc->delete($insert_id);
81  $this->assertEquals($result,true);
82  }
83  }
84 */
86  {
87  $obj = new assSingleChoice();
88  $this->assertEquals(false, $obj->isComplete());
89  $obj->setTitle('Tilte');
90  $obj->setAuthor('Me or another');
91  $obj->setQuestion('My great Question.');
92  $obj->addAnswer('Super simple single Choice', 1);
93 
94  $this->assertEquals(true, $obj->isComplete());
95  }
96 
98  {
99  $obj = new assSingleChoice();
100  $this->assertEquals('thumb.', $obj->getThumbPrefix());
101  }
102 
104  {
105  $obj = new assSingleChoice();
106  $obj->setOutputType(0);
107  $this->assertEquals(0, $obj->getOutputType());
108  }
109 
111  {
112  $obj = new assSingleChoice();
113  $this->assertEquals(0, $obj->getAnswerCount());
114  $obj->addAnswer('1', 1, 0);
115  $obj->addAnswer('1', 1, 1);
116  $this->assertEquals(2, $obj->getAnswerCount());
117  $obj->deleteAnswer(0);
118  $this->assertEquals(1, $obj->getAnswerCount());
119  }
120 
122  {
123  $obj = new assSingleChoice();
124  $obj->addAnswer('1', 1, 0);
125  $obj->addAnswer('1', 1, 1);
126  $this->assertEquals(2, $obj->getAnswerCount());
127  $obj->flushAnswers();
128  $this->assertEquals(0, $obj->getAnswerCount());
129  }
130 
132  {
133  $obj = new assSingleChoice();
134  $this->assertEquals('assSingleChoice', $obj->getQuestionType());
135  }
136 
138  {
139  $obj = new assSingleChoice();
140  $this->assertEquals('qpl_qst_sc', $obj->getAdditionalTableName());
141  }
142 
144  {
145  $obj = new assSingleChoice();
146  $this->assertEquals('qpl_a_sc', $obj->getAnswerTableName());
147  }
148 }
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.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27