ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assClozeTestTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $backupGlobals = false;
14
15 protected function setUp()
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 }
42
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 }
53
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 }
66
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 }
78
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 }
91
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 }
109
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 }
122
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 }
140
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 }
152
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 }
165
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 }
177
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 }
189
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 }
202}
An exception for terminatinating execution or to throw for unit testing.
Class assBaseTestCase.
setGlobalVariable($name, $value)
test_setGetFixedTextLength_shouldReturnValueUnchanged()
test_setGetIdenticalScoring_shouldReturnValueUnchanged()
test_setGetStartTag_defaultShoulBeApplied()
test_instantiateObject_shouldReturnInstance()
test_setGetEndTag_shouldReturnValueUnchanged()
test_isComplete_shouldReturnFalseIfIncomplete()
test_cleanQuestionText_shouldReturnCleanedText()
test_getQuestionType_shouldReturnQuestionType()
test_getAnswerTableName_shouldReturnAnswerTableName()
test_setGetStartTag_shouldReturnValueUnchanged()
test_getAdditionalTableName_shouldReturnAdditionalTableName()
Class for cloze tests.