ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

◆ setUp()

assErrorTextTest::setUp ( )
protected

Definition at line 15 of file assErrorTextTest.php.

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 require_once './Services/UICore/classes/class.ilCtrl.php';
25 $ilCtrl_mock = $this->createMock('ilCtrl');
26 $ilCtrl_mock->expects($this->any())->method('saveParameter');
27 $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
28 global $ilCtrl;
29 $ilCtrl = $ilCtrl_mock;
30
31 require_once './Services/Language/classes/class.ilLanguage.php';
32 $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
33 //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
34 global $lng;
35 $lng = $lng_mock;
36
37 $ilias_mock = new stdClass();
38 $ilias_mock->account = new stdClass();
39 $ilias_mock->account->id = 6;
40 $ilias_mock->account->fullname = 'Esther Tester';
41 global $ilias;
42 $ilias = $ilias_mock;
43 }
44 }
global $ilCtrl
Definition: ilias.php:18
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
global $lng
Definition: privfeed.php:17

References $ilCtrl, $lng, and defined.

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 58 of file assErrorTextTest.php.

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

◆ test_getErrorsFromText_emptyArgShouldPullInternal()

assErrorTextTest::test_getErrorsFromText_emptyArgShouldPullInternal ( )

Definition at line 103 of file assErrorTextTest.php.

104 {
105 // Arrange
106 require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
107 $instance = new assErrorText();
108
109 $errortext = '
110 Eine ((Kündigung)) kommt durch zwei gleichlautende Willenserklärungen zustande.
111 Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
112 Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
113 Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes)) Handeln.';
114
115 $expected = array(
116 'passages' => array( 0 => 'Kündigung', 1=> 'drei gleichlaute', 3 => 'konsequentes'),
117 'words' => array( 2 => 'Supermarkt')
118 );
119
120 // Act
121 $instance->setErrorText($errortext);
122 $actual = $instance->getErrorsFromText('');
123
124 // Assert
125 $this->assertEquals($expected, $actual);
126 }

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 82 of file assErrorTextTest.php.

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

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 46 of file assErrorTextTest.php.

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

◆ test_setErrordata_newError()

assErrorTextTest::test_setErrordata_newError ( )

Definition at line 128 of file assErrorTextTest.php.

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

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 148 of file assErrorTextTest.php.

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

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: