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

Unit tests for assErrorTextTest. More...

+ Inheritance diagram for assErrorTextTest:
+ Collaboration diagram for assErrorTextTest:

Public Member Functions

 test_instantiateObjectSimple ()
 test_getErrorsFromText ()
 test_getErrorsFromText_noMatch ()
 test_getErrorsFromText_emptyArgShouldPullInternal ()
 test_setErrordata_newError ()
 test_setErrordata_oldErrordataPresent ()

Protected Member Functions

 setUp ()

Protected Attributes

 $backupGlobals = FALSE

Detailed Description

Unit tests for assErrorTextTest.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 11 of file assErrorTextTest.php.

Member Function Documentation

assErrorTextTest::setUp ( )
protected

Definition at line 15 of file assErrorTextTest.php.

References $ilCtrl, and $lng.

{
if (defined('ILIAS_PHPUNIT_CONTEXT'))
{
include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
ilUnitUtil::performInitialisation();
}
else
{
chdir( dirname( __FILE__ ) );
chdir('../../../');
require_once './Services/UICore/classes/class.ilCtrl.php';
$ilCtrl_mock = $this->getMock('ilCtrl');
$ilCtrl_mock->expects( $this->any() )->method( 'saveParameter' );
$ilCtrl_mock->expects( $this->any() )->method( 'saveParameterByClass' );
global $ilCtrl;
$ilCtrl = $ilCtrl_mock;
require_once './Services/Language/classes/class.ilLanguage.php';
$lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
//$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
global $lng;
$lng = $lng_mock;
$ilias_mock = new stdClass();
$ilias_mock->account = new stdClass();
$ilias_mock->account->id = 6;
$ilias_mock->account->fullname = 'Esther Tester';
global $ilias;
$ilias = $ilias_mock;
}
}
assErrorTextTest::test_getErrorsFromText ( )

Definition at line 61 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
$instance = new assErrorText();
$errortext = '
Eine ((Kündigung)) kommt durch zwei gleichlautende Willenserklärungen zustande.
Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes)) Handeln.';
$expected = array(
'passages' => array( 0 => 'Kündigung', 1=> 'drei gleichlaute', 3 => 'konsequentes'),
'words' => array( 2 => 'Supermarkt')
);
// Act
$actual = $instance->getErrorsFromText($errortext);
// Assert
$this->assertEquals($expected, $actual);
}
assErrorTextTest::test_getErrorsFromText_emptyArgShouldPullInternal ( )

Definition at line 106 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
$instance = new assErrorText();
$errortext = '
Eine ((Kündigung)) kommt durch zwei gleichlautende Willenserklärungen zustande.
Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes)) Handeln.';
$expected = array(
'passages' => array( 0 => 'Kündigung', 1=> 'drei gleichlaute', 3 => 'konsequentes'),
'words' => array( 2 => 'Supermarkt')
);
// Act
$instance->setErrorText($errortext);
$actual = $instance->getErrorsFromText('');
// Assert
$this->assertEquals($expected, $actual);
}
assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 85 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
$instance = new assErrorText();
$errortext = '
Eine Kündigung)) kommt durch zwei gleichlautende (Willenserklärungen) zustande.
Ein Vertrag kommt durch (drei gleichlaute) Willenserklärungen zustande.
Ein Kaufvertrag an der Kasse im Supermarkt [kommt] durch das legen von Ware auf das
Kassierband und den [[Kassiervorgang]] zustande. Dies nennt man *konsequentes Handeln.';
$expected = array();
// Act
$actual = $instance->getErrorsFromText($errortext);
// Assert
$this->assertEquals($expected, $actual);
}
assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 49 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
// Act
$instance = new assErrorText();
// Assert
$this->assertInstanceOf('assErrorText', $instance);
}
assErrorTextTest::test_setErrordata_newError ( )

Definition at line 131 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
$instance = new assErrorText();
$errordata = array ('passages' => array ( 0 => 'drei Matrosen'), 'words' => array());
require_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
$expected = new assAnswerErrorText($errordata['passages'][0], '', 0.0);
// Act
$instance->setErrorData($errordata);
$all_errors = $instance->getErrorData();
$actual = $all_errors[0];
// Assert
$this->assertEquals($expected, $actual);
}
assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 151 of file assErrorTextTest.php.

{
// Arrange
require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
$instance = new assErrorText();
$errordata = array ('passages' => array ( 0 => 'drei Matrosen'), 'words' => array());
require_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
$expected = new assAnswerErrorText($errordata['passages'][0], '', 0);
$instance->errordata = $expected;
// Act
$instance->setErrorData($errordata);
$all_errors = $instance->getErrorData();
$actual = $all_errors[0];
// Assert
$this->assertEquals($expected, $actual);
}

Field Documentation

assErrorTextTest::$backupGlobals = FALSE
protected

Definition at line 13 of file assErrorTextTest.php.


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