ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assClozeTestTest Class Reference

Unit tests. More...

+ Inheritance diagram for assClozeTestTest:
+ Collaboration diagram for assClozeTestTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_cleanQuestionText_shouldReturnCleanedText ()
 
 test_isComplete_shouldReturnFalseIfIncomplete ()
 
 test_setGetStartTag_shouldReturnValueUnchanged ()
 
 test_setGetStartTag_defaultShoulBeApplied ()
 
 test_setGetEndTag_shouldReturnValueUnchanged ()
 
 test_setGetEndTag_defaultShoulBeApplied ()
 
 test_getQuestionType_shouldReturnQuestionType ()
 
 test_setGetIdenticalScoring_shouldReturnValueUnchanged ()
 
 test_getAdditionalTableName_shouldReturnAdditionalTableName ()
 
 test_getAnswerTableName_shouldReturnAnswerTableName ()
 
 test_setGetFixedTextLength_shouldReturnValueUnchanged ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests.

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

Definition at line 11 of file assClozeTestTest.php.

Member Function Documentation

◆ setUp()

assClozeTestTest::setUp ( )
protected

Definition at line 15 of file assClozeTestTest.php.

References $ilCtrl, $lng, array, and defined.

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  require_once './Services/UICore/classes/class.ilCtrl.php';
25  $ilCtrl_mock = $this->createMock('ilCtrl');
26  $ilCtrl_mock->expects($this->any())->method('saveParameter');
27  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
28  global $ilCtrl;
29  $ilCtrl = $ilCtrl_mock;
30 
31  require_once './Services/Language/classes/class.ilLanguage.php';
32  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
33  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
34  global $lng;
35  $lng = $lng_mock;
36 
37  $ilias_mock = new stdClass();
38  $ilias_mock->account = new stdClass();
39  $ilias_mock->account->id = 6;
40  $ilias_mock->account->fullname = 'Esther Tester';
41  global $ilias;
42  $ilias = $ilias_mock;
43  }
44  }
global $ilCtrl
Definition: ilias.php:18
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ test_cleanQuestionText_shouldReturnCleanedText()

assClozeTestTest::test_cleanQuestionText_shouldReturnCleanedText ( )

Definition at line 57 of file assClozeTestTest.php.

58  {
59  // Arrange
60  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
61  $instance = new assClozeTest();
62  $in_text = 'Ein <gap>Männlein</gap> steht <gap id="Walter">im</gap> <b>Walde</b> ganz <gap 2>still</gap> und [gap]stumm[/gap]<hr />';
63  $expected = 'Ein [gap]Männlein[/gap] steht [gap]im[/gap] <b>Walde</b> ganz [gap]still[/gap] und [gap]stumm[/gap]<hr />';
64 
65  $actual = $instance->cleanQuestiontext($in_text);
66 
67  $this->assertEquals($expected, $actual);
68  }
Class for cloze tests.

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assClozeTestTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 169 of file assClozeTestTest.php.

170  {
171  // Arrange
172  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
173  $instance = new assClozeTest();
174  $expected = 'qpl_qst_cloze';
175 
176  $actual = $instance->getAdditionalTableName();
177 
178  $this->assertEquals($expected, $actual);
179  }
Class for cloze tests.

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assClozeTestTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 181 of file assClozeTestTest.php.

References array.

182  {
183  // Arrange
184  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
185  $instance = new assClozeTest();
186  $expected = array("qpl_a_cloze",'qpl_a_cloze_combi_res');
187 
188  $actual = $instance->getAnswerTableName();
189 
190  $this->assertEquals($expected, $actual);
191  }
Class for cloze tests.
Create styles array
The data for the language used.

◆ test_getQuestionType_shouldReturnQuestionType()

assClozeTestTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 144 of file assClozeTestTest.php.

145  {
146  // Arrange
147  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
148  $instance = new assClozeTest();
149  $expected = 'assClozeTest';
150 
151  $actual = $instance->getQuestionType();
152 
153  $this->assertEquals($expected, $actual);
154  }
Class for cloze tests.

◆ test_instantiateObject_shouldReturnInstance()

assClozeTestTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 46 of file assClozeTestTest.php.

47  {
48  // Arrange
49  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
50 
51  // Act
52  $instance = new assClozeTest();
53 
54  $this->assertInstanceOf('assClozeTest', $instance);
55  }
Class for cloze tests.

◆ test_isComplete_shouldReturnFalseIfIncomplete()

assClozeTestTest::test_isComplete_shouldReturnFalseIfIncomplete ( )

Definition at line 70 of file assClozeTestTest.php.

71  {
72  // Arrange
73  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
74  $instance = new assClozeTest();
75  $expected = false;
76 
77  $actual = $instance->isComplete();
78 
79  $this->assertEquals($expected, $actual);
80  }
Class for cloze tests.

◆ test_setGetEndTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetEndTag_defaultShoulBeApplied ( )

Definition at line 126 of file assClozeTestTest.php.

127  {
128  // Arrange
129  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
130  $instance = new assClozeTest();
131  $alternate_tag = '</gappo_the_great>';
132  $expected = '[/gap]';
133 
134  $instance->setEndTag($alternate_tag);
135  $intermediate = $instance->getEndTag();
136  $this->assertEquals($alternate_tag, $intermediate);
137 
138  $instance->setEndTag();
139  $actual = $instance->getEndTag();
140 
141  $this->assertEquals($expected, $actual);
142  }
Class for cloze tests.

◆ test_setGetEndTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetEndTag_shouldReturnValueUnchanged ( )

Definition at line 113 of file assClozeTestTest.php.

114  {
115  // Arrange
116  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
117  $instance = new assClozeTest();
118  $expected = '</gappo_the_great>';
119 
120  $instance->setEndTag($expected);
121  $actual = $instance->getEndTag();
122 
123  $this->assertEquals($expected, $actual);
124  }
Class for cloze tests.

◆ test_setGetFixedTextLength_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetFixedTextLength_shouldReturnValueUnchanged ( )

Definition at line 193 of file assClozeTestTest.php.

194  {
195  // Arrange
196  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
197  $instance = new assClozeTest();
198  $expected = 123;
199 
200  $instance->setFixedTextLength($expected);
201  $actual = $instance->getFixedTextLength();
202 
203  $this->assertEquals($expected, $actual);
204  }
Class for cloze tests.

◆ test_setGetIdenticalScoring_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetIdenticalScoring_shouldReturnValueUnchanged ( )

Definition at line 156 of file assClozeTestTest.php.

157  {
158  // Arrange
159  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
160  $instance = new assClozeTest();
161  $expected = 1;
162 
163  $instance->setIdenticalScoring(true);
164  $actual = $instance->getIdenticalScoring();
165 
166  $this->assertEquals($expected, $actual);
167  }
Class for cloze tests.

◆ test_setGetStartTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetStartTag_defaultShoulBeApplied ( )

Definition at line 95 of file assClozeTestTest.php.

96  {
97  // Arrange
98  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
99  $instance = new assClozeTest();
100  $alternate_tag = '<gappo_the_great>';
101  $expected = '[gap]';
102 
103  $instance->setStartTag($alternate_tag);
104  $intermediate = $instance->getStartTag();
105  $this->assertEquals($alternate_tag, $intermediate);
106 
107  $instance->setStartTag();
108  $actual = $instance->getStartTag();
109 
110  $this->assertEquals($expected, $actual);
111  }
Class for cloze tests.

◆ test_setGetStartTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetStartTag_shouldReturnValueUnchanged ( )

Definition at line 82 of file assClozeTestTest.php.

83  {
84  // Arrange
85  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
86  $instance = new assClozeTest();
87  $expected = '<gappo_the_great>';
88 
89  $instance->setStartTag($expected);
90  $actual = $instance->getStartTag();
91 
92  $this->assertEquals($expected, $actual);
93  }
Class for cloze tests.

Field Documentation

◆ $backupGlobals

assClozeTestTest::$backupGlobals = false
protected

Definition at line 13 of file assClozeTestTest.php.


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