ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilassMultipleChoiceTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  protected $backupGlobals = FALSE;
36 
37  protected function setUp()
38  {
39  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
41  }
42 
49  public static function createSampleQuestion($obj_id = null)
50  {
51  $obj_id = ($obj_id) ? $obj_id : 99999999;
52  include_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
53 
54  $mc = new assMultipleChoice('unit test multiple choice question', 'unit test multiple choice question comment', 'Helmut Schottmüller', -1, '<p><strong>unit tests</strong> are...</p>');
55  $mc->addAnswer(
56  'important',
57  0.5,
58  -0.5,
59  1
60  );
61  $mc->addAnswer(
62  'useless',
63  -0.5,
64  0.5,
65  2
66  );
67  $mc->addAnswer(
68  'stupid',
69  -0.5,
70  0.5,
71  3
72  );
73  $mc->addAnswer(
74  'cool',
75  0.5,
76  -0.5,
77  4
78  );
79  $mc->setObjId($obj_id);
80  $mc->saveToDb();
81  return $mc->getId();
82  }
83 
89  public function testCreation()
90  {
91  global $ilDB;
92 
93  include_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
95  $this->assertGreaterThan(0, $insert_id);
96  if ($insert_id > 0)
97  {
98  $mc = new assMultipleChoice();
99  $mc->loadFromDb($insert_id);
100  $this->assertEquals($mc->getPoints(),2);
101  $this->assertEquals($mc->getTitle(),"unit test multiple choice question");
102  $this->assertEquals($mc->getComment(),"unit test multiple choice question comment");
103  $this->assertEquals($mc->getAuthor(),"Helmut Schottmüller");
104  $this->assertEquals($mc->getQuestion(),"<p><strong>unit tests</strong> are...</p>");
105  $this->assertEquals(count($mc->getAnswers()), 4);
106  $result = $mc->delete($insert_id);
107  $this->assertEquals($result,true);
108  }
109  }
110 }
111 ?>