ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 Member Functions inherited from assBaseTestCase
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

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.

References assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

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  parent::setUp();
25 
26  require_once './Services/UICore/classes/class.ilCtrl.php';
27  $ilCtrl_mock = $this->createMock('ilCtrl');
28  $ilCtrl_mock->expects($this->any())->method('saveParameter');
29  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
30  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
31 
32  require_once './Services/Language/classes/class.ilLanguage.php';
33  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
34  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
35  $this->setGlobalVariable('lng', $lng_mock);
36 
37  $this->setGlobalVariable('ilias', $this->getIliasMock());
38  $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
39  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
40  }
41  }
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ test_getErrorsFromText()

assErrorTextTest::test_getErrorsFromText ( )

Definition at line 55 of file assErrorTextTest.php.

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

◆ test_getErrorsFromText_emptyArgShouldPullInternal()

assErrorTextTest::test_getErrorsFromText_emptyArgShouldPullInternal ( )

Definition at line 100 of file assErrorTextTest.php.

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

◆ test_getErrorsFromText_noMatch()

assErrorTextTest::test_getErrorsFromText_noMatch ( )

Definition at line 79 of file assErrorTextTest.php.

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

◆ test_instantiateObjectSimple()

assErrorTextTest::test_instantiateObjectSimple ( )

Definition at line 43 of file assErrorTextTest.php.

44  {
45  // Arrange
46  require_once './Modules/TestQuestionPool/classes/class.assErrorText.php';
47 
48  // Act
49  $instance = new assErrorText();
50 
51  // Assert
52  $this->assertInstanceOf('assErrorText', $instance);
53  }
Class for error text questions.

◆ test_setErrordata_newError()

assErrorTextTest::test_setErrordata_newError ( )

Definition at line 125 of file assErrorTextTest.php.

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

◆ test_setErrordata_oldErrordataPresent()

assErrorTextTest::test_setErrordata_oldErrordataPresent ( )

Definition at line 145 of file assErrorTextTest.php.

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

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: