ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilassSingleChoiceTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for ilassSingleChoiceTest:
+ Collaboration diagram for ilassSingleChoiceTest:

Public Member Functions

 testCreation ()
 Question creation test.

Static Public Member Functions

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

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:
ilassSingleChoiceTest.php 19383 2009-03-15 11:27:25Z hschottm

Definition at line 33 of file ilassSingleChoiceTest.php.

Member Function Documentation

static ilassSingleChoiceTest::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 49 of file ilassSingleChoiceTest.php.

Referenced by testCreation().

{
$obj_id = ($obj_id) ? $obj_id : 99999999;
include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
$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>');
$sc->addAnswer(
'Yes',
1,
0,
1
);
$sc->addAnswer(
'No',
-1,
0,
2
);
$sc->setObjId($obj_id);
$sc->saveToDb();
return $sc->getId();
}

+ Here is the caller graph for this function:

ilassSingleChoiceTest::setUp ( )
protected

Definition at line 37 of file ilassSingleChoiceTest.php.

References ilUnitUtil\performInitialisation().

{
include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
}

+ Here is the call graph for this function:

ilassSingleChoiceTest::testCreation ( )

Question creation test.

Parameters
@return

Definition at line 76 of file ilassSingleChoiceTest.php.

References $ilDB, $result, and createSampleQuestion().

{
global $ilDB;
include_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
$this->assertGreaterThan(0, $insert_id);
if ($insert_id > 0)
{
$sc = new assSingleChoice();
$sc->loadFromDb($insert_id);
$this->assertEquals($sc->getPoints(),1);
$this->assertEquals($sc->getTitle(),"unit test single choice question");
$this->assertEquals($sc->getComment(),"unit test single choice question comment");
$this->assertEquals($sc->getAuthor(),"Helmut Schottmüller");
$this->assertEquals($sc->getQuestion(),"<p>is a <strong>unit test</strong> required?</p>");
$this->assertEquals(count($sc->getAnswers()), 2);
$result = $sc->delete($insert_id);
$this->assertEquals($result,true);
}
}

+ Here is the call graph for this function:

Field Documentation

ilassSingleChoiceTest::$backupGlobals = FALSE
protected

Definition at line 35 of file ilassSingleChoiceTest.php.


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