ILIAS  release_4-4 Revision
assSingleChoiceTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for assSingleChoiceTest:
+ Collaboration diagram for assSingleChoiceTest:

Public Member Functions

 t_e_stCreation ()
 Question creation test. More...
 

Static Public Member Functions

static createSampleQuestion ($obj_id=null)
 Create a sample question and save it to the database. More...
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Unit tests for single choice questions.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file assSingleChoiceTest.php.

Member Function Documentation

◆ createSampleQuestion()

static assSingleChoiceTest::createSampleQuestion (   $obj_id = null)
static

Create a sample question and save it to the database.

Parameters
integer$obj_idObject ID of the containing question pool object (optional)
Returns
integer ID of the newly created question

Definition at line 37 of file assSingleChoiceTest.php.

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  }
Class for single choice questions.

◆ setUp()

assSingleChoiceTest::setUp ( )
protected

Definition at line 17 of file assSingleChoiceTest.php.

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  }

◆ t_e_stCreation()

assSingleChoiceTest::t_e_stCreation ( )

Question creation test.

Parameters

Definition at line 64 of file assSingleChoiceTest.php.

References $result.

65  {
66  global $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  }
$result
Class for single choice questions.

Field Documentation

◆ $backupGlobals

assSingleChoiceTest::$backupGlobals = FALSE
protected

Definition at line 15 of file assSingleChoiceTest.php.


The documentation for this class was generated from the following file: