ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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_setErrordata_newError ()
 
 test_setErrordata_oldErrordataPresent ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

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

◆ setUp()

assErrorTextTest::setUp ( )
protected

Reimplemented from assBaseTestCase.

Definition at line 15 of file assErrorTextTest.php.

15 : void
16 {
17 if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19 ilUnitUtil::performInitialisation();
20 } else {
21 chdir(dirname(__FILE__));
22 chdir('../../../');
23
24 parent::setUp();
25
26 require_once './Services/UICore/classes/class.ilCtrl.php';
27 $ilCtrl_mock = $this->createMock('ilCtrl');
28 $ilCtrl_mock->expects($this->any())->method('saveParameter');
29 $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
30 $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
31
32 require_once './Services/Language/classes/class.ilLanguage.php';
33 $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
34 //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
35 $this->setGlobalVariable('lng', $lng_mock);
36
37 $this->setGlobalVariable('ilias', $this->getIliasMock());
38 $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
39 $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
40 }
41 }
setGlobalVariable($name, $value)

References assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

+ Here is the call graph for this function:

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 55 of file assErrorTextTest.php.

56 {
57 // Arrange
58 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
59 $instance = new assErrorText();
60
61 $errortext = '
62 Eine ((Kündigung)) kommt durch zwei gleichlautende Willenserklärungen zustande.
63 Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
64 Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
65 Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes)) Handeln.';
66
67 $expected = array(
68 'passages' => array( 0 => 'Kündigung', 1 => 'drei gleichlaute', 3 => 'konsequentes'),
69 'words' => array( 2 => 'Supermarkt')
70 );
71
72 // Act
73 $actual = $instance->getErrorsFromText($errortext);
74
75 // Assert
76 $this->assertEquals($expected, $actual);
77 }
Class for error text questions.

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 79 of file assErrorTextTest.php.

80 {
81 // Arrange
82 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
83 $instance = new assErrorText();
84
85 $errortext = '
86 Eine Kündigung)) kommt durch zwei gleichlautende (Willenserklärungen) zustande.
87 Ein Vertrag kommt durch (drei gleichlaute) Willenserklärungen zustande.
88 Ein Kaufvertrag an der Kasse im Supermarkt [kommt] durch das legen von Ware auf das
89 Kassierband und den [[Kassiervorgang]] zustande. Dies nennt man *konsequentes Handeln.';
90
91 $expected = array();
92
93 // Act
94 $actual = $instance->getErrorsFromText($errortext);
95
96 // Assert
97 $this->assertEquals($expected, $actual);
98 }

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 43 of file assErrorTextTest.php.

44 {
45 // Arrange
46 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
47
48 // Act
49 $instance = new assErrorText();
50
51 // Assert
52 $this->assertInstanceOf('assErrorText', $instance);
53 }

◆ test_setErrordata_newError()

assErrorTextTest::test_setErrordata_newError ( )

Definition at line 126 of file assErrorTextTest.php.

127 {
128 // Arrange
129 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
130 $instance = new assErrorText();
131
132 $errordata = array('passages' => array( 0 => 'drei Matrosen'), 'words' => array());
133 require_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
134 $expected = new assAnswerErrorText($errordata['passages'][0], '', 0.0);
135
136 // Act
137 $instance->setErrorData($errordata);
138
139 $all_errors = $instance->getErrorData();
140 $actual = $all_errors[0];
141
142 // Assert
143 $this->assertEquals($expected, $actual);
144 }
Class for error text answers.

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 146 of file assErrorTextTest.php.

147 {
148 // Arrange
149 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
150 $instance = new assErrorText();
151
152 $errordata = array('passages' => array( 0 => 'drei Matrosen'), 'words' => array());
153 require_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
154 $expected = new assAnswerErrorText($errordata['passages'][0], '', 0);
155 $instance->errordata = $expected;
156
157 // Act
158 $instance->setErrorData($errordata);
159
160 $all_errors = $instance->getErrorData();
161 $actual = $all_errors[0];
162
163 // Assert
164 $this->assertEquals($expected, $actual);
165 }

Field Documentation

◆ $backupGlobals

assErrorTextTest::$backupGlobals = false
protected

Definition at line 13 of file assErrorTextTest.php.


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