ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
assErrorTextTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 test_instantiateObjectSimple ()
 
 test_getErrorsFromText ()
 
 test_getErrorsFromText_noMatch ()
 
 test_setErrordata ()
 
 test_setErrordata_oldErrordataPresent ()
 
 test_removeErrorDataWithoutPosition ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 getIRSSMock ()
 

Protected Attributes

 $backupGlobals = false
 
- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Unit tests for assErrorTextTest

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

\

Definition at line 26 of file assErrorTextTest.php.

Member Function Documentation

◆ setUp()

assErrorTextTest::setUp ( )
protected

Definition at line 30 of file assErrorTextTest.php.

References getDatabaseMock(), getIliasMock(), and setGlobalVariable().

30  : void
31  {
32  chdir(__DIR__ . '/../../../../');
33 
34  parent::setUp();
35 
36  $ilCtrl_mock = $this->createMock('ilCtrl');
37  $ilCtrl_mock->expects($this->any())->method('saveParameter');
38  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
39  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
40 
41  $lng_mock = $this->createMock('ilLanguage', ['txt'], [], '', false);
42  $this->setGlobalVariable('lng', $lng_mock);
43 
44  $this->setGlobalVariable('ilias', $this->getIliasMock());
45  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
46  }
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 55 of file assErrorTextTest.php.

55  : void
56  {
57  $this->markTestSkipped('Generates warning for some unknown reason.');
58 
59  $instance = new assErrorText();
60  $instance->setPointsWrong(-2);
61 
62  $errortext = '
63  Eine Kündigung kommt durch zwei ((gleichlautende Willenserklärungen zustande)).
64  Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
65  Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
66  Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes Handeln.))';
67 
68  $expected = [
69  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 6),
70  new assAnswerErrorText('drei gleichlaute', '', 0.0, 13),
71  new assAnswerErrorText('Supermarkt', '', 0.0, 23),
72  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 40),
73  ];
74 
75  $instance->setErrorText($errortext);
76  $instance->parseErrorText();
77  $instance->setErrorsFromParsedErrorText();
78  $actual = $instance->getErrorData();
79 
80  $this->assertEquals($expected, $actual);
81  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for error text questions.

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 83 of file assErrorTextTest.php.

83  : void
84  {
85  $this->markTestSkipped('Generates warning for some unknown reason.');
86 
87  $instance = new assErrorText();
88  $instance->setPointsWrong(-2);
89 
90  $errortext = '
91  Eine Kündigung)) kommt durch zwei gleichlautende (Willenserklärungen) zustande.
92  Ein Vertrag kommt durch (drei gleichlaute) Willenserklärungen zustande.
93  Ein Kaufvertrag an der Kasse im Supermarkt [kommt] durch das legen von Ware auf das
94  Kassierband und den [[Kassiervorgang]] zustande. Dies nennt man *konsequentes Handeln.';
95 
96  $expected = [];
97 
98  $instance->setErrorText($errortext);
99  $instance->parseErrorText();
100  $instance->setErrorsFromParsedErrorText();
101  $actual = $instance->getErrorData();
102 
103  $this->assertEquals($expected, $actual);
104  }
Class for error text questions.

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 48 of file assErrorTextTest.php.

48  : void
49  {
50  $instance = new assErrorText();
51 
52  $this->assertInstanceOf(assErrorText::class, $instance);
53  }
Class for error text questions.

◆ test_removeErrorDataWithoutPosition()

assErrorTextTest::test_removeErrorDataWithoutPosition ( )

Definition at line 144 of file assErrorTextTest.php.

144  : void
145  {
146  $instance = new assErrorText();
147  $instance->setPointsWrong(-2);
148 
149  $parsed_errortext = [
150  0 => [
151  ['text' => '1', 'error_type' => 'none'],
152  [
153  'text' => 'gleichlautende',
154  'text_wrong' => 'gleichlautende Willenserklärungen zustande.',
155  'error_type' => 'passage_start',
156  'error_position' => 1,
157  'text_correct' => '',
158  'points' => 1,
159  ],
160  ['text' => '2', 'error_type' => 'none'],
161  [
162  'text' => 'Supermarkt',
163  'text_wrong' => 'Supermarkt',
164  'error_type' => 'word',
165  'error_position' => 3,
166  'text_correct' => '',
167  'points' => 1,
168  ],
169  ]
170  ];
171 
172  $errordata = [
173  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0),
174  new assAnswerErrorText('drei gleichlaute', '', 0.0),
175  new assAnswerErrorText('Supermarkt', '', 0.0),
176  new assAnswerErrorText('konsequentes Handeln.', '', ),
177  ];
178  $expected = [
179  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 1),
180  new assAnswerErrorText('Supermarkt', '', 0.0, 3),
181  ];
182 
183  $instance->setParsedErrorText($parsed_errortext);
184  $instance->setErrorData($errordata);
185  $instance->removeErrorDataWithoutPosition();
186  $actual = $instance->getErrorData();
187 
188  $this->assertEquals($expected, $actual);
189  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for error text questions.

◆ test_setErrordata()

assErrorTextTest::test_setErrordata ( )

Definition at line 106 of file assErrorTextTest.php.

References null.

106  : void
107  {
108  $instance = new assErrorText();
109  $instance->setPointsWrong(-2);
110 
111  $errordata = [new assAnswerErrorText('drei Matrosen')];
112  $expected = [new assAnswerErrorText('drei Matrosen', '', 0.0, null)];
113  $instance->setErrorData($errordata);
114  $actual = $instance->getErrorData();
115 
116  $this->assertEquals($expected, $actual);
117  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class for error text questions.

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 119 of file assErrorTextTest.php.

119  : void
120  {
121  $instance = new assErrorText();
122  $instance->setPointsWrong(-2);
123 
124  $old_errordata = [
125  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 6),
126  new assAnswerErrorText('drei gleichlaute', '', 0.0, 13),
127  new assAnswerErrorText('Supermarkt', '', 0.0, 23),
128  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 40),
129  ];
130  $new_errordata = [
131  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 2),
132  new assAnswerErrorText('drei gleichlaute', '', 0.0, 3),
133  new assAnswerErrorText('Supermarkt', '', 0.0, 11),
134  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 32),
135  ];
136 
137  $instance->setErrorData($old_errordata);
138  $instance->setErrorData($new_errordata);
139 
140  $actual = $instance->getErrorData();
141 
142  $this->assertEquals($new_errordata, $actual);
143  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for error text questions.

Field Documentation

◆ $backupGlobals

assErrorTextTest::$backupGlobals = false
protected

Definition at line 28 of file assErrorTextTest.php.


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