ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilassMarkSchemaTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for ilassMarkSchemaTest:
+ Collaboration diagram for ilassMarkSchemaTest:

Public Member Functions

 testConstructor ()
 Test constructor.
 testCreateSimpleSchemaDefaults ()
 Test for createSimpleSchema using defaults.
 testCreateSimpleSchemaCustom ()
 Test for createSimpleSchema using custom values.
 testFlush ()
 Test for flush()
 testAddMarkStep ()
 Test for addMarkStep()
 testSaveToDb_regular ()

Protected Member Functions

 setUp ()

Protected Attributes

 $backupGlobals = FALSE

Detailed Description

Unit tests for single choice questions.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
Id:
ilassMarkSchemaTest.php 44245 2013-08-17 11:15:45Z mbecker

Definition at line 13 of file ilassMarkSchemaTest.php.

Member Function Documentation

ilassMarkSchemaTest::setUp ( )
protected

Definition at line 17 of file ilassMarkSchemaTest.php.

{
if (defined('ILIAS_PHPUNIT_CONTEXT'))
{
include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
ilUnitUtil::performInitialisation();
}
else
{
chdir( dirname( __FILE__ ) );
chdir('../../../');
}
// Arrange
include_once './Modules/Test/classes/class.assMarkSchema.php';
$this->ass_mark_schema = new ASS_MarkSchema();
}
ilassMarkSchemaTest::testAddMarkStep ( )

Test for addMarkStep()

Definition at line 225 of file ilassMarkSchemaTest.php.

{
// Arrange
$this->ass_mark_schema->flush();
$txt_short = "";
$txt_official = "";
$percentage = 0;
$passed = 0;
// Act
$this->ass_mark_schema->addMarkStep();
$mark_schema = $this->ass_mark_schema->mark_steps;
$mark_step = $mark_schema[0];
// Assert
$this->assertEquals(
$mark_step->getShortName(),
$txt_short,
'Failed on $txt_failed_short'
);
$this->assertEquals(
$mark_step->getOfficialName(),
$txt_official,
'Failed on $txt_failed_official'
);
$this->assertEquals(
$mark_step->getMinimumLevel(),
$percentage,
'Failed on $percentage_failed'
);
$this->assertEquals(
$mark_step->getPassed(),
$passed,
'Failed on $failed_passed'
);
}
ilassMarkSchemaTest::testConstructor ( )

Test constructor.

Definition at line 37 of file ilassMarkSchemaTest.php.

{
// Arrange
$expected = is_array(array());
// Act
$actual = is_array($this->ass_mark_schema->mark_steps);
// Assert
$this->assertEquals(
$actual,
$expected,
"Constructor failed, mark_steps not an array."
);
}
ilassMarkSchemaTest::testCreateSimpleSchemaCustom ( )

Test for createSimpleSchema using custom values.

Definition at line 126 of file ilassMarkSchemaTest.php.

References $failed.

{
// Arrange
$txt_failed_short = "failed";
$txt_failed_official = "failed";
$percentage_failed = 0;
$failed_passed = 0;
$txt_passed_short = "passed";
$txt_passed_official = "passed";
$percentage_passed = 50;
$passed_passed = 1;
// Act
$this->ass_mark_schema->createSimpleSchema(
$txt_failed_short,
$txt_failed_official,
$percentage_failed,
$failed_passed,
$txt_passed_short,
$txt_passed_official,
$percentage_passed,
$passed_passed
);
$marks = $this->ass_mark_schema->mark_steps;
$failed = $marks[0];
$passed = $marks[1];
// Assert
$this->assertEquals(
$failed->getShortName(),
$txt_failed_short,
'Failed on $txt_failed_short'
);
$this->assertEquals(
$failed->getOfficialName(),
$txt_failed_official,
'Failed on $txt_failed_official'
);
$this->assertEquals(
$failed->getMinimumLevel(),
$percentage_failed,
'Failed on $percentage_failed'
);
$this->assertEquals(
$failed->getPassed(),
$failed_passed,
'Failed on $failed_passed'
);
$this->assertEquals(
$passed->getShortName(),
$txt_passed_short,
'Failed on $txt_passed_short'
);
$this->assertEquals(
$passed->getOfficialName(),
$txt_passed_official,
'Failed on $txt_passed_official'
);
$this->assertEquals(
$passed->getMinimumLevel(),
$percentage_passed,
'Failed on $percetage_passed'
);
$this->assertEquals(
$passed->getPassed(),
$passed_passed,
'Failed on $passed_passed'
);
}
ilassMarkSchemaTest::testCreateSimpleSchemaDefaults ( )

Test for createSimpleSchema using defaults.

Definition at line 57 of file ilassMarkSchemaTest.php.

References $failed.

{
// Arrange
$txt_failed_short = "failed";
$txt_failed_official = "failed";
$percentage_failed = 0;
$failed_passed = 0;
$txt_passed_short = "passed";
$txt_passed_official = "passed";
$percentage_passed = 50;
$passed_passed = 1;
// Act
$this->ass_mark_schema->createSimpleSchema();
$marks = $this->ass_mark_schema->mark_steps;
$failed = $marks[0];
$passed = $marks[1];
// Assert
$this->assertEquals(
$failed->getShortName(),
$txt_failed_short,
'Failed on $txt_failed_short'
);
$this->assertEquals(
$failed->getOfficialName(),
$txt_failed_official,
'Failed on $txt_failed_official'
);
$this->assertEquals(
$failed->getMinimumLevel(),
$percentage_failed,
'Failed on $percentage_failed'
);
$this->assertEquals(
$failed->getPassed(),
$failed_passed,
'Failed on $failed_passed'
);
$this->assertEquals(
$passed->getShortName(),
$txt_passed_short,
'Failed on $txt_passed_short'
);
$this->assertEquals(
$passed->getOfficialName(),
$txt_passed_official,
'Failed on $txt_passed_official'
);
$this->assertEquals(
$passed->getMinimumLevel(),
$percentage_passed,
'Failed on $percetage_passed'
);
$this->assertEquals(
$passed->getPassed(),
$passed_passed,
'Failed on $passed_passed'
);
}
ilassMarkSchemaTest::testFlush ( )

Test for flush()

Definition at line 202 of file ilassMarkSchemaTest.php.

{
// Arrange
$expected = is_array(array());
$this->ass_mark_schema->mark_steps = "a string";
$this->assertEquals($this->ass_mark_schema->mark_steps, "a string");
$this->ass_mark_schema->flush();
// Act
$actual = is_array($this->ass_mark_schema->mark_steps);
// Assert
$this->assertEquals(
$actual,
$expected,
"Method failed, mark_steps not an array."
);
}
ilassMarkSchemaTest::testSaveToDb_regular ( )

Definition at line 262 of file ilassMarkSchemaTest.php.

{
/*
// Arrange
require_once 'Services/Database/classes/class.ilDB.php';
$ildb_stub = $this->getMock('ilDB');
$ildb_stub->expects($this->any())
->method('query')
->will($this->returnValue('foo'));
$ildb_stub->expects($this->any())
->method('numRows')
->will($this->returnValue(1));
$db_result_1 = array('cmi_node_id' => 8);
$db_result_2 = array('cmi_node_id' => 10);
$db_result_3 = array('cmi_node_id' => 12);
$db_result_4 = array('cmi_node_id' => 14);
$ildb_stub->expects($this->any())
->method('fetchAssoc')
->will($this->onConsecutiveCalls($db_result_1, $db_result_2, $db_result_3, $db_result_4));
*/
}

Field Documentation

ilassMarkSchemaTest::$backupGlobals = FALSE
protected

Definition at line 15 of file ilassMarkSchemaTest.php.


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