ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assMultipleChoiceTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for assMultipleChoiceTest:
+ Collaboration diagram for assMultipleChoiceTest:

Public Member Functions

 t_e_stCreation ()
 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:
assMultipleChoiceTest.php 44245 2013-08-17 11:15:45Z mbecker

Definition at line 13 of file assMultipleChoiceTest.php.

Member Function Documentation

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

Referenced by t_e_stCreation().

{
$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:

assMultipleChoiceTest::setUp ( )
protected

Definition at line 17 of file assMultipleChoiceTest.php.

{
if (defined('ILIAS_PHPUNIT_CONTEXT'))
{
include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
ilUnitUtil::performInitialisation();
}
else
{
chdir( dirname( __FILE__ ) );
chdir('../../../');
}
}
assMultipleChoiceTest::t_e_stCreation ( )

Question creation test.

Parameters
@return

Definition at line 77 of file assMultipleChoiceTest.php.

References $result, and createSampleQuestion().

{
global $ilDB;
include_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
$insert_id = self::createSampleQuestion(null);
$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

assMultipleChoiceTest::$backupGlobals = FALSE
protected

Definition at line 15 of file assMultipleChoiceTest.php.


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