ILIAS  release_7 Revision v7.30-3-g800a261c036
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() : void
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 $expected = false;
60
61 $actual = $instance->isComplete();
62
63 $this->assertEquals($expected, $actual);
64 }
65
67 {
68 // Arrange
69 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
70 $instance = new assClozeTest();
71 $expected = '<gappo_the_great>';
72
73 $instance->setStartTag($expected);
74 $actual = $instance->getStartTag();
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 $alternate_tag = '<gappo_the_great>';
85 $expected = '[gap]';
86
87 $instance->setStartTag($alternate_tag);
88 $intermediate = $instance->getStartTag();
89 $this->assertEquals($alternate_tag, $intermediate);
90
91 $instance->setStartTag();
92 $actual = $instance->getStartTag();
93
94 $this->assertEquals($expected, $actual);
95 }
96
98 {
99 // Arrange
100 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
101 $instance = new assClozeTest();
102 $expected = '</gappo_the_great>';
103
104 $instance->setEndTag($expected);
105 $actual = $instance->getEndTag();
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 $alternate_tag = '</gappo_the_great>';
116 $expected = '[/gap]';
117
118 $instance->setEndTag($alternate_tag);
119 $intermediate = $instance->getEndTag();
120 $this->assertEquals($alternate_tag, $intermediate);
121
122 $instance->setEndTag();
123 $actual = $instance->getEndTag();
124
125 $this->assertEquals($expected, $actual);
126 }
127
129 {
130 // Arrange
131 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
132 $instance = new assClozeTest();
133 $expected = 'assClozeTest';
134
135 $actual = $instance->getQuestionType();
136
137 $this->assertEquals($expected, $actual);
138 }
139
141 {
142 // Arrange
143 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
144 $instance = new assClozeTest();
145 $expected = 1;
146
147 $instance->setIdenticalScoring(true);
148 $actual = $instance->getIdenticalScoring();
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 = 'qpl_qst_cloze';
159
160 $actual = $instance->getAdditionalTableName();
161
162 $this->assertEquals($expected, $actual);
163 }
164
166 {
167 // Arrange
168 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
169 $instance = new assClozeTest();
170 $expected = array("qpl_a_cloze",'qpl_a_cloze_combi_res');
171
172 $actual = $instance->getAnswerTableName();
173
174 $this->assertEquals($expected, $actual);
175 }
176
178 {
179 // Arrange
180 require_once './Modules/TestQuestionPool/classes/class.assClozeTest.php';
181 $instance = new assClozeTest();
182 $expected = 123;
183
184 $instance->setFixedTextLength($expected);
185 $actual = $instance->getFixedTextLength();
186
187 $this->assertEquals($expected, $actual);
188 }
189}
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_getQuestionType_shouldReturnQuestionType()
test_getAnswerTableName_shouldReturnAnswerTableName()
test_setGetStartTag_shouldReturnValueUnchanged()
test_getAdditionalTableName_shouldReturnAdditionalTableName()
Class for cloze tests.