ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assClozeTestTest.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  protected $backupGlobals = false;
29 
30  protected function setUp(): void
31  {
32  parent::setUp();
33 
34  $ilCtrl_mock = $this->getMockBuilder(ilCtrl::class)
35  ->disableOriginalConstructor()
36  ->getMock();
37  $ilCtrl_mock->method('saveParameter');
38  $ilCtrl_mock->method('saveParameterByClass');
39  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
40 
41  $lng_mock = $this->getMockBuilder(ilLanguage::class)
42  ->disableOriginalConstructor()
43  ->onlyMethods(['txt'])
44  ->getMock();
45  $lng_mock->method('txt')->will($this->returnValue('Test'));
46  $this->setGlobalVariable('lng', $lng_mock);
47 
48  $this->setGlobalVariable('ilias', $this->getIliasMock());
49  $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
50  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
51  }
52 
54  {
55  // Act
56  $instance = new assClozeTest();
57 
58  $this->assertInstanceOf('assClozeTest', $instance);
59  }
60 
62  {
63  $instance = new assClozeTest();
64  $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 />';
65  $expected = 'Ein [gap]Männlein[/gap] steht [gap]im[/gap] <b>Walde</b> ganz [gap]still[/gap] und [gap]stumm[/gap]<hr />';
66 
67  $actual = $instance->cleanQuestiontext($in_text);
68 
69  $this->assertEquals($expected, $actual);
70  }
71 
73  {
74  $instance = new assClozeTest();
75  $expected = false;
76 
77  $actual = $instance->isComplete();
78 
79  $this->assertEquals($expected, $actual);
80  }
81 
83  {
84  $instance = new assClozeTest();
85  $expected = '<gappo_the_great>';
86 
87  $instance->setStartTag($expected);
88  $actual = $instance->getStartTag();
89 
90  $this->assertEquals($expected, $actual);
91  }
92 
94  {
95  $instance = new assClozeTest();
96  $alternate_tag = '<gappo_the_great>';
97  $expected = '[gap]';
98 
99  $instance->setStartTag($alternate_tag);
100  $intermediate = $instance->getStartTag();
101  $this->assertEquals($alternate_tag, $intermediate);
102 
103  $instance->setStartTag();
104  $actual = $instance->getStartTag();
105 
106  $this->assertEquals($expected, $actual);
107  }
108 
110  {
111  $instance = new assClozeTest();
112  $expected = '</gappo_the_great>';
113 
114  $instance->setEndTag($expected);
115  $actual = $instance->getEndTag();
116 
117  $this->assertEquals($expected, $actual);
118  }
119 
121  {
122  $instance = new assClozeTest();
123  $alternate_tag = '</gappo_the_great>';
124  $expected = '[/gap]';
125 
126  $instance->setEndTag($alternate_tag);
127  $intermediate = $instance->getEndTag();
128  $this->assertEquals($alternate_tag, $intermediate);
129 
130  $instance->setEndTag();
131  $actual = $instance->getEndTag();
132 
133  $this->assertEquals($expected, $actual);
134  }
135 
137  {
138  $instance = new assClozeTest();
139  $expected = 'assClozeTest';
140 
141  $actual = $instance->getQuestionType();
142 
143  $this->assertEquals($expected, $actual);
144  }
145 
147  {
148  $instance = new assClozeTest();
149  $expected = 1;
150 
151  $instance->setIdenticalScoring(true);
152  $actual = $instance->getIdenticalScoring();
153 
154  $this->assertEquals($expected, $actual);
155  }
156 
158  {
159  $instance = new assClozeTest();
160  $expected = 'qpl_qst_cloze';
161 
162  $actual = $instance->getAdditionalTableName();
163 
164  $this->assertEquals($expected, $actual);
165  }
166 
168  {
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  $instance = new assClozeTest();
180  $expected = 123;
181 
182  $instance->setFixedTextLength($expected);
183  $actual = $instance->getFixedTextLength();
184 
185  $this->assertEquals($expected, $actual);
186  }
187 }
test_instantiateObject_shouldReturnInstance()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
test_isComplete_shouldReturnFalseIfIncomplete()
Class assBaseTestCase.
test_setGetFixedTextLength_shouldReturnValueUnchanged()
test_getAdditionalTableName_shouldReturnAdditionalTableName()
test_getQuestionType_shouldReturnQuestionType()
test_setGetIdenticalScoring_shouldReturnValueUnchanged()
test_getAnswerTableName_shouldReturnAnswerTableName()
test_cleanQuestionText_shouldReturnCleanedText()
test_setGetStartTag_defaultShoulBeApplied()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
test_setGetStartTag_shouldReturnValueUnchanged()
test_setGetEndTag_shouldReturnValueUnchanged()
setGlobalVariable(string $name, $value)