ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
19 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20 ilUnitUtil::performInitialisation();
21 }
22 else
23 {
24 chdir( dirname( __FILE__ ) );
25 chdir('../../../');
26
27 require_once './Services/UICore/classes/class.ilCtrl.php';
28 $ilCtrl_mock = $this->getMock('ilCtrl');
29 $ilCtrl_mock->expects( $this->any() )->method( 'saveParameter' );
30 $ilCtrl_mock->expects( $this->any() )->method( 'saveParameterByClass' );
31 global $ilCtrl;
32 $ilCtrl = $ilCtrl_mock;
33
34 require_once './Services/Language/classes/class.ilLanguage.php';
35 $lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
36 //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
37 global $lng;
38 $lng = $lng_mock;
39
40 $ilias_mock = new stdClass();
41 $ilias_mock->account = new stdClass();
42 $ilias_mock->account->id = 6;
43 $ilias_mock->account->fullname = 'Esther Tester';
44 global $ilias;
45 $ilias = $ilias_mock;
46 }
47 }
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

References $ilCtrl, and $lng.

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 61 of file assErrorTextTest.php.

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

◆ test_getErrorsFromText_emptyArgShouldPullInternal()

assErrorTextTest::test_getErrorsFromText_emptyArgShouldPullInternal ( )

Definition at line 106 of file assErrorTextTest.php.

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

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 85 of file assErrorTextTest.php.

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

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 49 of file assErrorTextTest.php.

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

◆ test_setErrordata_newError()

assErrorTextTest::test_setErrordata_newError ( )

Definition at line 131 of file assErrorTextTest.php.

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

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 151 of file assErrorTextTest.php.

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

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: