ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir( dirname( __FILE__ ) );
25  chdir('../../../');
26 
27  require_once './Services/UICore/classes/class.ilCtrl.php';
28  $ilCtrl_mock = $this->getMock('ilCtrl');
29  $ilCtrl_mock->expects( $this->any() )->method( 'saveParameter' );
30  $ilCtrl_mock->expects( $this->any() )->method( 'saveParameterByClass' );
31  global $ilCtrl;
32  $ilCtrl = $ilCtrl_mock;
33 
34  require_once './Services/Language/classes/class.ilLanguage.php';
35  $lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
36  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
37  global $lng;
38  $lng = $lng_mock;
39 
40  $ilias_mock = new stdClass();
41  $ilias_mock->account = new stdClass();
42  $ilias_mock->account->id = 6;
43  $ilias_mock->account->fullname = 'Esther Tester';
44  global $ilias;
45  $ilias = $ilias_mock;
46  }
47  }
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 60 of file assClozeTestTest.php.

61  {
62  // Arrange
63  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
64  $instance = new assClozeTest();
65  $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 />';
66  $expected = 'Ein [gap]Männlein[/gap] steht [gap]im[/gap] <b>Walde</b> ganz [gap]still[/gap] und [gap]stumm[/gap]<hr />';
67 
68  $actual = $instance->cleanQuestiontext($in_text);
69 
70  $this->assertEquals($expected, $actual);
71  }
Class for cloze tests.

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assClozeTestTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 172 of file assClozeTestTest.php.

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

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assClozeTestTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 184 of file assClozeTestTest.php.

References array.

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

◆ test_getQuestionType_shouldReturnQuestionType()

assClozeTestTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 147 of file assClozeTestTest.php.

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

◆ test_instantiateObject_shouldReturnInstance()

assClozeTestTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 49 of file assClozeTestTest.php.

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

◆ test_isComplete_shouldReturnFalseIfIncomplete()

assClozeTestTest::test_isComplete_shouldReturnFalseIfIncomplete ( )

Definition at line 73 of file assClozeTestTest.php.

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

◆ test_setGetEndTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetEndTag_defaultShoulBeApplied ( )

Definition at line 129 of file assClozeTestTest.php.

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

◆ test_setGetEndTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetEndTag_shouldReturnValueUnchanged ( )

Definition at line 116 of file assClozeTestTest.php.

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

◆ test_setGetFixedTextLength_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetFixedTextLength_shouldReturnValueUnchanged ( )

Definition at line 196 of file assClozeTestTest.php.

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

◆ test_setGetIdenticalScoring_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetIdenticalScoring_shouldReturnValueUnchanged ( )

Definition at line 159 of file assClozeTestTest.php.

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

◆ test_setGetStartTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetStartTag_defaultShoulBeApplied ( )

Definition at line 98 of file assClozeTestTest.php.

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

◆ test_setGetStartTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetStartTag_shouldReturnValueUnchanged ( )

Definition at line 85 of file assClozeTestTest.php.

86  {
87  // Arrange
88  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
89  $instance = new assClozeTest();
90  $expected = '<gappo_the_great>';
91 
92  $instance->setStartTag($expected);
93  $actual = $instance->getStartTag();
94 
95  $this->assertEquals($expected, $actual);
96  }
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: