ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  if (defined('ILIAS_PHPUNIT_CONTEXT'))
20  {
21  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
22  ilUnitUtil::performInitialisation();
23  }
24  else
25  {
26  chdir( dirname( __FILE__ ) );
27  chdir('../../../');
28  }
29  }
30 
37  public static function createSampleQuestion($obj_id = null)
38  {
39  $obj_id = ($obj_id) ? $obj_id : 99999999;
40  include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
41  $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>');
42  $sc->addAnswer(
43  'Yes',
44  1,
45  0,
46  1
47  );
48  $sc->addAnswer(
49  'No',
50  -1,
51  0,
52  2
53  );
54  $sc->setObjId($obj_id);
55  $sc->saveToDb();
56  return $sc->getId();
57  }
58 
64  public function t_e_stCreation()
65  {
66  global $ilDB;
67 
68  include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
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 }