ILIAS  release_7 Revision v7.30-3-g800a261c036
ilTermsOfServiceSettingsFormGUITest Class Reference

Class ilTermsOfServiceSettingsFormGUITest. More...

+ Inheritance diagram for ilTermsOfServiceSettingsFormGUITest:
+ Collaboration diagram for ilTermsOfServiceSettingsFormGUITest:

Public Member Functions

 testFormCanBeProperlyBuilt ()
 
 testFormCanBeSavedWithDisabledService ()
 
 testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists ()
 
 testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled ()
 
 testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ testFormCanBeProperlyBuilt()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeProperlyBuilt ( )
Exceptions
ReflectionException

Definition at line 13 of file ilTermsOfServiceSettingsFormGUITest.php.

13 : void
14 {
15 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
16
17 $tos
18 ->expects($this->any())
19 ->method('getStatus')
20 ->willReturn(true);
21
23 $tos,
24 '',
25 'save',
26 true
27 );
28
29 $this->assertCount(1, $form->getCommandButtons(), 'Failed asserting save button is given if form is editable');
30 $this->assertArrayHasKey(
31 0,
32 $form->getCommandButtons(),
33 'Failed asserting save button ist given if form is editable'
34 );
35 $this->assertEquals(
36 'save',
37 $form->getCommandButtons()[0]['cmd'],
38 'Failed asserting save button ist given if form is editable'
39 );
40
42 $tos,
43 '',
44 'save',
45 false
46 );
47
48 $this->assertCount(
49 0,
50 $form->getCommandButtons(),
51 'Failed asserting no button is given if form is not editable'
52 );
53 }
Class ilTermsOfServiceSettingsFormGUI.

◆ testFormCanBeSavedWithDisabledService()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithDisabledService ( )
Exceptions
ReflectionException

Definition at line 58 of file ilTermsOfServiceSettingsFormGUITest.php.

58 : void
59 {
60 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
61
62 $tos
63 ->expects($this->any())
64 ->method('getStatus')
65 ->willReturn(false);
66
67 $tos
68 ->expects($this->once())
69 ->method('saveStatus')
70 ->with(false);
71
72 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
73 ->setConstructorArgs([
74 $tos,
75 '',
76 'save',
77 true
78 ])
79 ->onlyMethods(['checkInput', 'getInput'])
80 ->getMock();
81
82 $form
83 ->expects($this->once())
84 ->method('checkInput')
85 ->willReturn(true);
86
87 $form
88 ->expects($this->exactly(2))
89 ->method('getInput')
90 ->willReturn(0);
91
92 $_POST = [
93 'tos_status' => 1
94 ];
95
96 $form->setCheckInputCalled(true);
97
98 $this->assertTrue($form->saveObject());
99 $this->assertFalse($form->hasTranslatedError());
100 $this->assertEmpty($form->getTranslatedError());
101 }
$_POST["username"]

References $_POST.

◆ testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithEnabledServiceWhenAtLeastOneDocumentExists ( )
Exceptions
ReflectionException

Definition at line 106 of file ilTermsOfServiceSettingsFormGUITest.php.

106 : void
107 {
108 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
109
110 $tos
111 ->expects($this->any())
112 ->method('getStatus')
113 ->willReturn(false);
114
115 $tos
116 ->expects($this->once())
117 ->method('saveStatus')
118 ->with(true);
119
120 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
121 ->setConstructorArgs([
122 $tos,
123 '',
124 'save',
125 true
126 ])
127 ->onlyMethods(['checkInput', 'getInput'])
128 ->getMock();
129
130 $form
131 ->expects($this->once())
132 ->method('checkInput')
133 ->willReturn(true);
134
135 $form
136 ->expects($this->exactly(3))
137 ->method('getInput')
138 ->willReturn(1);
139
140 $_POST = [
141 'tos_status' => 1,
142 'tos_reevaluate_on_login' => 1,
143 ];
144
145 $form->setCheckInputCalled(true);
146
147 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();
148
149 $documentConnector
150 ->expects($this->once())
151 ->method('affectedRows')
152 ->willReturn(2);
153
154 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
155
156 $this->assertTrue($form->saveObject());
157 $this->assertFalse($form->hasTranslatedError());
158 $this->assertEmpty($form->getTranslatedError());
159 }
static register(ActiveRecord $ar, arConnector $connector)
Class ilTermsOfServiceDocument.

References $_POST, and arConnectorMap\register().

+ Here is the call graph for this function:

◆ testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled()

ilTermsOfServiceSettingsFormGUITest::testFormCanBeSavedWithEnabledServiceWhenNoDocumentsExistButServiceIsAlreadyEnabled ( )
Exceptions
ReflectionException

Definition at line 229 of file ilTermsOfServiceSettingsFormGUITest.php.

229 : void
230 {
231 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
232
233 $tos
234 ->expects($this->any())
235 ->method('getStatus')
236 ->willReturn(true);
237
238 $tos
239 ->expects($this->once())
240 ->method('saveStatus');
241
242 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
243 ->setConstructorArgs([
244 $tos,
245 '',
246 'save',
247 true
248 ])
249 ->onlyMethods(['checkInput', 'getInput'])
250 ->getMock();
251
252 $form
253 ->expects($this->once())
254 ->method('checkInput')
255 ->willReturn(true);
256
257 $form
258 ->expects($this->exactly(3))
259 ->method('getInput')
260 ->willReturn(1);
261
262 $_POST = [
263 'tos_status' => 1,
264 'tos_reevaluate_on_login' => 1,
265 ];
266
267 $form->setCheckInputCalled(true);
268
269 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();#
270
271 $documentConnector
272 ->expects($this->once())
273 ->method('affectedRows')
274 ->willReturn(0);
275
276 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
277
278 $this->assertTrue($form->saveObject());
279 $this->assertFalse($form->hasTranslatedError());
280 $this->assertEmpty($form->getTranslatedError());
281 }

References $_POST, and arConnectorMap\register().

+ Here is the call graph for this function:

◆ testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled()

ilTermsOfServiceSettingsFormGUITest::testFormCannotBeSavedWithEnabledServiceWhenNoDocumentsExistAndServiceIsCurrentlyDisabled ( )
Exceptions
ReflectionException

Definition at line 164 of file ilTermsOfServiceSettingsFormGUITest.php.

164 : void
165 {
166 $lng = $this->getLanguageMock();
167
168 $lng
169 ->expects($this->any())
170 ->method('txt')
171 ->willReturn('translation');
172
173 $this->setGlobalVariable('lng', $lng);
174
175 $tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
176
177 $tos
178 ->expects($this->any())
179 ->method('getStatus')
180 ->willReturn(false);
181
182 $tos
183 ->expects($this->never())
184 ->method('saveStatus');
185
186 $form = $this->getMockBuilder(ilTermsOfServiceSettingsFormGUI::class)
187 ->setConstructorArgs([
188 $tos,
189 '',
190 'save',
191 true
192 ])
193 ->onlyMethods(['checkInput', 'getInput'])
194 ->getMock();
195
196 $form
197 ->expects($this->once())
198 ->method('checkInput')
199 ->willReturn(true);
200
201 $form
202 ->expects($this->once())
203 ->method('getInput')
204 ->willReturn(1);
205
206 $_POST = [
207 'tos_status' => 1
208 ];
209
210 $form->setCheckInputCalled(true);
211
212 $documentConnector = $this->getMockBuilder(arConnector::class)->getMock();#
213
214 $documentConnector
215 ->expects($this->once())
216 ->method('affectedRows')
217 ->willReturn(0);
218
219 arConnectorMap::register(new ilTermsOfServiceDocument(), $documentConnector);
220
221 $this->assertFalse($form->saveObject());
222 $this->assertTrue($form->hasTranslatedError());
223 $this->assertNotEmpty($form->getTranslatedError());
224 }
setGlobalVariable(string $name, $value)
$lng

References $_POST, $lng, ilTermsOfServiceBaseTest\getLanguageMock(), arConnectorMap\register(), and ilTermsOfServiceBaseTest\setGlobalVariable().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: