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

Unit tests for single choice questions. More...

+ Inheritance diagram for ilassMultipleChoiceTest:
+ Collaboration diagram for ilassMultipleChoiceTest:

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

Definition at line 33 of file ilassMultipleChoiceTest.php.

Member Function Documentation

static ilassMultipleChoiceTest::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 ilassMultipleChoiceTest.php.

Referenced by testCreation().

{
$obj_id = ($obj_id) ? $obj_id : 99999999;
include_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
$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>');
$mc->addAnswer(
'important',
0.5,
-0.5,
1
);
$mc->addAnswer(
'useless',
-0.5,
0.5,
2
);
$mc->addAnswer(
'stupid',
-0.5,
0.5,
3
);
$mc->addAnswer(
'cool',
0.5,
-0.5,
4
);
$mc->setObjId($obj_id);
$mc->saveToDb();
return $mc->getId();
}

+ Here is the caller graph for this function:

ilassMultipleChoiceTest::setUp ( )
protected

Definition at line 37 of file ilassMultipleChoiceTest.php.

References ilUnitUtil\performInitialisation().

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

+ Here is the call graph for this function:

ilassMultipleChoiceTest::testCreation ( )

Question creation test.

Parameters
@return

Definition at line 89 of file ilassMultipleChoiceTest.php.

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

{
global $ilDB;
include_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
$this->assertGreaterThan(0, $insert_id);
if ($insert_id > 0)
{
$mc = new assMultipleChoice();
$mc->loadFromDb($insert_id);
$this->assertEquals($mc->getPoints(),2);
$this->assertEquals($mc->getTitle(),"unit test multiple choice question");
$this->assertEquals($mc->getComment(),"unit test multiple choice question comment");
$this->assertEquals($mc->getAuthor(),"Helmut Schottmüller");
$this->assertEquals($mc->getQuestion(),"<p><strong>unit tests</strong> are...</p>");
$this->assertEquals(count($mc->getAnswers()), 4);
$result = $mc->delete($insert_id);
$this->assertEquals($result,true);
}
}

+ Here is the call graph for this function:

Field Documentation

ilassMultipleChoiceTest::$backupGlobals = FALSE
protected

Definition at line 35 of file ilassMultipleChoiceTest.php.


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