ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.

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

Definition at line 13 of file assSingleChoiceTest.php.

Member Function Documentation

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.

Referenced by t_e_stCreation().

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

assSingleChoiceTest::setUp ( )
protected

Definition at line 17 of file assSingleChoiceTest.php.

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

Question creation test.

Parameters
@return

Definition at line 64 of file assSingleChoiceTest.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

assSingleChoiceTest::$backupGlobals = FALSE
protected

Definition at line 15 of file assSingleChoiceTest.php.


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