ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 getIRSSMock ()
 
 getFileDeliveryMock ()
 
 getIliasMock ()
 
 addGlobal_uiFactory ()
 
 addGlobal_uiRenderer ()
 

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  $ilCtrl_mock = $this->createMock('ilCtrl');
38  $ilCtrl_mock->expects($this->any())->method('saveParameter');
39  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
40  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
41 
42  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
43  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
44  $this->setGlobalVariable('lng', $lng_mock);
45 
46  $this->setGlobalVariable('ilias', $this->getIliasMock());
47  $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
48  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
49  }
setGlobalVariable(string $name, $value)
+ Here is the call graph for this function:

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 60 of file assErrorTextTest.php.

60  : void
61  {
62  $instance = new assErrorText();
63  $instance->setPointsWrong(-2);
64 
65  $errortext = '
66  Eine Kündigung kommt durch zwei ((gleichlautende Willenserklärungen zustande)).
67  Ein Vertrag kommt durch ((drei gleichlaute)) Willenserklärungen zustande.
68  Ein Kaufvertrag an der Kasse im #Supermarkt kommt durch das legen von Ware auf das
69  Kassierband und den Kassiervorgang zustande. Dies nennt man ((konsequentes Handeln.))';
70 
71  $expected = [
72  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 6),
73  new assAnswerErrorText('drei gleichlaute', '', 0.0, 13),
74  new assAnswerErrorText('Supermarkt', '', 0.0, 23),
75  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 40)
76  ];
77 
78  $instance->setErrorText($errortext);
79  $instance->parseErrorText();
80  $instance->setErrorsFromParsedErrorText();
81  $actual = $instance->getErrorData();
82 
83  $this->assertEquals($expected, $actual);
84  }
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 86 of file assErrorTextTest.php.

86  : void
87  {
88  $instance = new assErrorText();
89  $instance->setPointsWrong(-2);
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 = [];
98 
99  $instance->setErrorText($errortext);
100  $instance->parseErrorText();
101  $instance->setErrorsFromParsedErrorText();
102  $actual = $instance->getErrorData();
103 
104  $this->assertEquals($expected, $actual);
105  }
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 51 of file assErrorTextTest.php.

51  : void
52  {
53  // Act
54  $instance = new assErrorText();
55 
56  // Assert
57  $this->assertInstanceOf('assErrorText', $instance);
58  }
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 145 of file assErrorTextTest.php.

145  : void
146  {
147  $instance = new assErrorText();
148  $instance->setPointsWrong(-2);
149 
150  $parsed_errortext = [
151  0 => [
152  ['text' => '1', 'error_type' => 'none'],
153  [
154  'text' => 'gleichlautende',
155  'text_wrong' => 'gleichlautende Willenserklärungen zustande.',
156  'error_type' => 'passage_start',
157  'error_position' => 1,
158  'text_correct' => '',
159  'points' => 1
160  ],
161  ['text' => '2', 'error_type' => 'none'],
162  [
163  'text' => 'Supermarkt',
164  'text_wrong' => 'Supermarkt',
165  'error_type' => 'word',
166  'error_position' => 3,
167  'text_correct' => '',
168  'points' => 1
169  ]
170  ]
171  ];
172 
173  $errordata = [
174  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0),
175  new assAnswerErrorText('drei gleichlaute', '', 0.0),
176  new assAnswerErrorText('Supermarkt', '', 0.0),
177  new assAnswerErrorText('konsequentes Handeln.', '', )
178  ];
179  $expected = [
180  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 1),
181  new assAnswerErrorText('Supermarkt', '', 0.0, 3)
182  ];
183 
184  $instance->setParsedErrorText($parsed_errortext);
185  $instance->setErrorData($errordata);
186  $instance->removeErrorDataWithoutPosition();
187  $actual = $instance->getErrorData();
188 
189  $this->assertEquals($expected, $actual);
190  }
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 107 of file assErrorTextTest.php.

107  : void
108  {
109  $instance = new assErrorText();
110  $instance->setPointsWrong(-2);
111 
112  $errordata = [new assAnswerErrorText('drei Matrosen')];
113  $expected = [new assAnswerErrorText('drei Matrosen', '', 0.0, null)];
114  $instance->setErrorData($errordata);
115  $actual = $instance->getErrorData();
116 
117  $this->assertEquals($expected, $actual);
118  }
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 120 of file assErrorTextTest.php.

120  : void
121  {
122  $instance = new assErrorText();
123  $instance->setPointsWrong(-2);
124 
125  $old_errordata = [
126  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 6),
127  new assAnswerErrorText('drei gleichlaute', '', 0.0, 13),
128  new assAnswerErrorText('Supermarkt', '', 0.0, 23),
129  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 40)
130  ];
131  $new_errordata = [
132  new assAnswerErrorText('gleichlautende Willenserklärungen zustande.', '', 0.0, 2),
133  new assAnswerErrorText('drei gleichlaute', '', 0.0, 3),
134  new assAnswerErrorText('Supermarkt', '', 0.0, 11),
135  new assAnswerErrorText('konsequentes Handeln.', '', 0.0, 32)
136  ];
137 
138  $instance->setErrorData($old_errordata);
139  $instance->setErrorData($new_errordata);
140 
141  $actual = $instance->getErrorData();
142 
143  $this->assertEquals($new_errordata, $actual);
144  }
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: