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

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 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_cleanQuestionText_shouldReturnCleanedText()

assClozeTestTest::test_cleanQuestionText_shouldReturnCleanedText ( )

Definition at line 54 of file assClozeTestTest.php.

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

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assClozeTestTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 166 of file assClozeTestTest.php.

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

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assClozeTestTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 178 of file assClozeTestTest.php.

179  {
180  // Arrange
181  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
182  $instance = new assClozeTest();
183  $expected = array("qpl_a_cloze",'qpl_a_cloze_combi_res');
184 
185  $actual = $instance->getAnswerTableName();
186 
187  $this->assertEquals($expected, $actual);
188  }
Class for cloze tests.

◆ test_getQuestionType_shouldReturnQuestionType()

assClozeTestTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 141 of file assClozeTestTest.php.

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

◆ test_instantiateObject_shouldReturnInstance()

assClozeTestTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 43 of file assClozeTestTest.php.

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

◆ test_isComplete_shouldReturnFalseIfIncomplete()

assClozeTestTest::test_isComplete_shouldReturnFalseIfIncomplete ( )

Definition at line 67 of file assClozeTestTest.php.

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

◆ test_setGetEndTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetEndTag_defaultShoulBeApplied ( )

Definition at line 123 of file assClozeTestTest.php.

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

◆ test_setGetEndTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetEndTag_shouldReturnValueUnchanged ( )

Definition at line 110 of file assClozeTestTest.php.

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

◆ test_setGetFixedTextLength_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetFixedTextLength_shouldReturnValueUnchanged ( )

Definition at line 190 of file assClozeTestTest.php.

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

◆ test_setGetIdenticalScoring_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetIdenticalScoring_shouldReturnValueUnchanged ( )

Definition at line 153 of file assClozeTestTest.php.

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

◆ test_setGetStartTag_defaultShoulBeApplied()

assClozeTestTest::test_setGetStartTag_defaultShoulBeApplied ( )

Definition at line 92 of file assClozeTestTest.php.

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

◆ test_setGetStartTag_shouldReturnValueUnchanged()

assClozeTestTest::test_setGetStartTag_shouldReturnValueUnchanged ( )

Definition at line 79 of file assClozeTestTest.php.

80  {
81  // Arrange
82  require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
83  $instance = new assClozeTest();
84  $expected = '<gappo_the_great>';
85 
86  $instance->setStartTag($expected);
87  $actual = $instance->getStartTag();
88 
89  $this->assertEquals($expected, $actual);
90  }
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: