ILIAS  release_8 Revision v8.23
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 ()
 
 setGlobalVariable (string $name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

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 assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

30  : void
31  {
32  chdir(dirname(__FILE__));
33  chdir('../../../');
34 
35  parent::setUp();
36 
37  require_once './Services/UICore/classes/class.ilCtrl.php';
38  $ilCtrl_mock = $this->createMock('ilCtrl');
39  $ilCtrl_mock->expects($this->any())->method('saveParameter');
40  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
41  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
42 
43  require_once './Services/Language/classes/class.ilLanguage.php';
44  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
45  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
46  $this->setGlobalVariable('lng', $lng_mock);
47 
48  $this->setGlobalVariable('ilias', $this->getIliasMock());
49  $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
50  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
51  }
setGlobalVariable(string $name, $value)
+ Here is the call graph for this function:

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 65 of file assErrorTextTest.php.

65  : void
66  {
67  $instance = new assErrorText();
68  $instance->setPointsWrong(-2);
69 
70  $errortext = '
71  Eine Kündigung kommt durch zwei ((gleichlautende Willenserklärungen zustande)).
72  Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
73  Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
74  Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes Handeln.))';
75 
76  $expected = [
77  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 6),
78  new assAnswerErrorText('drei gleichlaute', '', 0.0, 13),
79  new assAnswerErrorText('Supermarkt', '', 0.0, 23),
80  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 40)
81  ];
82 
83  $instance->setErrorText($errortext);
84  $instance->parseErrorText();
85  $instance->setErrorsFromParsedErrorText();
86  $actual = $instance->getErrorData();
87 
88  $this->assertEquals($expected, $actual);
89  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 91 of file assErrorTextTest.php.

91  : void
92  {
93  $instance = new assErrorText();
94  $instance->setPointsWrong(-2);
95 
96  $errortext = '
97  Eine Kündigung)) kommt durch zwei gleichlautende (Willenserklärungen) zustande.
98  Ein Vertrag kommt durch (drei gleichlaute) Willenserklärungen zustande.
99  Ein Kaufvertrag an der Kasse im Supermarkt [kommt] durch das legen von Ware auf das
100  Kassierband und den [[Kassiervorgang]] zustande. Dies nennt man *konsequentes Handeln.';
101 
102  $expected = [];
103 
104  $instance->setErrorText($errortext);
105  $instance->parseErrorText();
106  $instance->setErrorsFromParsedErrorText();
107  $actual = $instance->getErrorData();
108 
109  $this->assertEquals($expected, $actual);
110  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 53 of file assErrorTextTest.php.

53  : void
54  {
55  // Arrange
56  require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
57 
58  // Act
59  $instance = new assErrorText();
60 
61  // Assert
62  $this->assertInstanceOf('assErrorText', $instance);
63  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_removeErrorDataWithoutPosition()

assErrorTextTest::test_removeErrorDataWithoutPosition ( )

Definition at line 150 of file assErrorTextTest.php.

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

◆ test_setErrordata()

assErrorTextTest::test_setErrordata ( )

Definition at line 112 of file assErrorTextTest.php.

112  : void
113  {
114  $instance = new assErrorText();
115  $instance->setPointsWrong(-2);
116 
117  $errordata = [new assAnswerErrorText('drei Matrosen')];
118  $expected = [new assAnswerErrorText('drei Matrosen', '', 0.0, null)];
119  $instance->setErrorData($errordata);
120  $actual = $instance->getErrorData();
121 
122  $this->assertEquals($expected, $actual);
123  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 125 of file assErrorTextTest.php.

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

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: