ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceDocumentGUITest Class Reference

Class ilTermsOfServiceDocumentGUITest. More...

+ Inheritance diagram for ilTermsOfServiceDocumentGUITest:
+ Collaboration diagram for ilTermsOfServiceDocumentGUITest:

Public Member Functions

 setUp ()
 
 commandProvider ()
 
 testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing (string $command, array $accessResults)
 @dataProvider commandProvider @expectedException \ilException More...
 
 testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ()
 
 testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ()
 

Protected Attributes

 $tableDataProviderFactory
 
 $tos
 
 $tpl
 
 $ctrl
 
 $lng
 
 $rbacsystem
 
 $error
 
 $user
 
 $log
 
 $uiFactory
 
 $uiRenderer
 
 $httpState
 
 $toolbar
 
 $fileUpload
 
 $fileSystems
 
 $criterionTypeFactory
 
 $documentPurifier
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ commandProvider()

ilTermsOfServiceDocumentGUITest::commandProvider ( )
Returns
string[]

Definition at line 96 of file ilTermsOfServiceDocumentGUITest.php.

96 : array
97 {
98 return [
99 ['default_____read', [false]],
100 ['confirmReset', [true, false]],
101 ['reset', [true, false]],
102 ['saveAddDocumentForm', [true, false]],
103 ['showAddDocumentForm', [true, false]],
104 ['saveEditDocumentForm', [true, false]],
105 ['showEditDocumentForm', [true, false]],
106 ['deleteDocuments', [true, false]],
107 ['saveDocumentSorting', [true, false]],
108 ['showAttachCriterionForm', [true, false]],
109 ['saveAttachCriterionForm', [true, false]],
110 ['showChangeCriterionForm', [true, false]],
111 ['saveChangeCriterionForm', [true, false]],
112 ['detachCriterionAssignment', [true, false]]
113 ];
114 }

◆ setUp()

ilTermsOfServiceDocumentGUITest::setUp ( )

Reimplemented from ilTermsOfServiceBaseTest.

Definition at line 70 of file ilTermsOfServiceDocumentGUITest.php.

71 {
72 parent::setUp();
73
74 $this->tos = $this->getMockBuilder(\ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
75 $this->criterionTypeFactory = $this->getMockBuilder(\ilTermsOfServiceCriterionTypeFactoryInterface::class)->disableOriginalConstructor()->getMock();
76 $this->tpl = $this->getMockBuilder(\ilTemplate::class)->disableOriginalConstructor()->setMethods(['g'])->getMock();
77 $this->ctrl = $this->getMockBuilder(\ilCtrl::class)->disableOriginalConstructor()->getMock();
78 $this->lng = $this->getMockBuilder(\ilLanguage::class)->disableOriginalConstructor()->getMock();
79 $this->rbacsystem = $this->getMockBuilder(\ilRbacSystem::class)->disableOriginalConstructor()->getMock();
80 $this->error = $this->getMockBuilder(\ilErrorHandling::class)->disableOriginalConstructor()->getMock();
81 $this->user = $this->getMockBuilder(\ilObjUser::class)->disableOriginalConstructor()->getMock();
82 $this->log = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
83 $this->toolbar = $this->getMockBuilder(\ilToolbarGUI::class)->disableOriginalConstructor()->getMock();
84 $this->httpState = $this->getMockBuilder(GlobalHttpState::class)->getMock();
85 $this->uiFactory = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock();
86 $this->uiRenderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
87 $this->fileSystems = $this->getMockBuilder(Filesystems::class)->getMock();
88 $this->fileUpload = $this->getMockBuilder(FileUpload::class)->getMock();
89 $this->tableDataProviderFactory = $this->getMockBuilder(\ilTermsOfServiceTableDataProviderFactory::class)->disableOriginalConstructor()->getMock();
90 $this->documentPurifier = $this->getMockBuilder(\ilHtmlPurifierInterface::class)->getMock();
91 }
user()
Definition: user.php:4
error($a_errmsg)
set error message @access public

References error(), and user().

+ Here is the call graph for this function:

◆ testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing()

ilTermsOfServiceDocumentGUITest::testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing ( string  $command,
array  $accessResults 
)

@dataProvider commandProvider @expectedException \ilException

Parameters
string$command
bool[]$accessResults

Definition at line 122 of file ilTermsOfServiceDocumentGUITest.php.

123 {
124 $this->tos
125 ->expects($this->any())
126 ->method('getRefId')
127 ->willReturn(4711);
128
129 $this->ctrl
130 ->expects($this->once())
131 ->method('getCmd')
132 ->willReturn($command);
133
134 $accessResultCounter = 0;
135 $this->rbacsystem
136 ->expects($this->exactly(count($accessResults)))
137 ->method('checkAccess')
138 ->willReturnCallback(function () use ($accessResults, &$accessResultCounter) {
139 $result = $accessResults[$accessResultCounter];
140
141 $accessResultCounter++;
142
143 return $result;
144 });
145
146 $this->error
147 ->expects($this->any())
148 ->method('raiseError')
149 ->willThrowException(new \ilException('no_permission'));
150
151 $gui = new \ilTermsOfServiceDocumentGUI(
152 $this->tos,
153 $this->criterionTypeFactory,
154 $this->tpl,
155 $this->user,
156 $this->ctrl,
157 $this->lng,
158 $this->rbacsystem,
159 $this->error,
160 $this->log,
161 $this->toolbar,
162 $this->httpState,
163 $this->uiFactory,
164 $this->uiRenderer,
165 $this->fileSystems,
166 $this->fileUpload,
167 $this->tableDataProviderFactory,
168 $this->documentPurifier
169 );
170
171 $this->assertException(\ilException::class);
172
173 $gui->executeCommand();
174 }
$result
Base class for ILIAS Exception handling.
assertException(string $exceptionClass)
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.

References $result, ilTermsOfServiceBaseTest\assertException(), error(), Sabre\Event\once(), and user().

+ Here is the call graph for this function:

◆ testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )

Definition at line 179 of file ilTermsOfServiceDocumentGUITest.php.

180 {
181 $this->setGlobalVariable('lng', clone $this->lng);
182 $this->setGlobalVariable('ilUser', clone $this->user);
183
184 $this->tos
185 ->expects($this->any())
186 ->method('getRefId')
187 ->willReturn(4711);
188
189 $lastResetDate = $this->getMockBuilder(\ilDate::class)
190 ->disableOriginalConstructor()
191 ->getMock();
192
193 $date = new \DateTime();
194
195 $lastResetDate->setDate($date->getTimestamp(), IL_CAL_UNIX);
196
197 $lastResetDate
198 ->expects($this->any())
199 ->method('get')
200 ->willReturn([
201 'seconds' => (int) $date->format('s'),
202 'minutes' => (int) $date->format('i'),
203 'hours' => (int) $date->format('G'),
204 'mday' => (int) $date->format('j'),
205 'wday' => (int) $date->format('w'),
206 'mon' => (int) $date->format('n'),
207 'year' => (int) $date->format('Y'),
208 'yday' => (int) $date->format('z'),
209 'weekday' => $date->format('l'),
210 'month' => $date->format('F'),
211 'isoday' => (int) $date->format('N')
212 ]);
213
214 $lastResetDate
215 ->expects($this->any())
216 ->method('isNull')
217 ->willReturn(true); // Required because of \ilDatePresentation static calls
218
219 $this->tos
220 ->expects($this->any())
221 ->method('getLastResetDate')
222 ->willReturn($lastResetDate);
223
224 $this->ctrl
225 ->expects($this->once())
226 ->method('getCmd')
227 ->willReturn('getResetMessageBoxHtml');
228
229 $this->ctrl
230 ->expects($this->once())
231 ->method('getLinkTarget')
232 ->with($this->isInstanceOf(\ilTermsOfServiceDocumentGUI::class), 'confirmReset')
233 ->willReturn('confirmReset');
234
235 $this->rbacsystem
236 ->expects($this->any())
237 ->method('checkAccess')
238 ->willReturn(true);
239
240 $buttonFactory = $this->getMockBuilder(\ILIAS\UI\Component\Button\Factory::class)->getMock();
241 $button = $this->getMockBuilder(\ILIAS\UI\Component\Button\Standard::class)->getMock();
242
243 $buttonFactory
244 ->expects($this->once())
245 ->method('standard')
246 ->with($this->isType('string'), $this->equalTo('confirmReset'))
247 ->willReturn($button);
248
249 $this->uiFactory
250 ->expects($this->once())
251 ->method('button')
252 ->willReturn($buttonFactory);
253
254 $messageBoxFactory = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\Factory::class)->getMock();
255 $info = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\MessageBox::class)->getMock();
256
257 $messageBoxFactory
258 ->expects($this->once())
259 ->method('info')
260 ->with($this->stringContains('Some date:'))
261 ->willReturn($info);
262
263 $info
264 ->expects($this->once())
265 ->method('withButtons')
266 ->with($this->countOf(1));
267
268 $this->uiFactory
269 ->expects($this->once())
270 ->method('messageBox')
271 ->willReturn($messageBoxFactory);
272
273 $this->error
274 ->expects($this->never())
275 ->method('raiseError');
276
277 $this->uiRenderer
278 ->expects($this->atLeast(1))
279 ->method('render')
280 ->willReturn('');
281
282 $this->lng
283 ->expects($this->exactly(2))
284 ->method('txt')
285 ->willReturnOnConsecutiveCalls(
286 'Some date: %s',
287 'Some button text'
288 );
289
290 $gui = new \ilTermsOfServiceDocumentGUI(
291 $this->tos,
292 $this->criterionTypeFactory,
293 $this->tpl,
294 $this->user,
295 $this->ctrl,
296 $this->lng,
297 $this->rbacsystem,
298 $this->error,
299 $this->log,
300 $this->toolbar,
301 $this->httpState,
302 $this->uiFactory,
303 $this->uiRenderer,
304 $this->fileSystems,
305 $this->fileUpload,
306 $this->tableDataProviderFactory,
307 $this->documentPurifier
308 );
309
310 $gui->executeCommand();
311 }
const IL_CAL_UNIX
setGlobalVariable(string $name, $value)
$info
Definition: index.php:5
Class BaseForm.
Class Factory.

References $info, error(), IL_CAL_UNIX, Sabre\Event\once(), ilTermsOfServiceBaseTest\setGlobalVariable(), and user().

+ Here is the call graph for this function:

◆ testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )

Definition at line 316 of file ilTermsOfServiceDocumentGUITest.php.

317 {
318 $this->setGlobalVariable('lng', clone $this->lng);
319 $this->setGlobalVariable('ilUser', clone $this->user);
320
321 $this->tos
322 ->expects($this->any())
323 ->method('getRefId')
324 ->willReturn(4711);
325
326 $lastResetDate = $this->getMockBuilder(\ilDate::class)
327 ->disableOriginalConstructor()
328 ->getMock();
329
330 $lastResetDate
331 ->expects($this->any())
332 ->method('get')
333 ->willReturn(0);
334 $lastResetDate
335 ->expects($this->any())
336 ->method('isNull')
337 ->willReturn(true);
338
339 $this->tos
340 ->expects($this->any())
341 ->method('getLastResetDate')
342 ->willReturn($lastResetDate);
343
344 $this->ctrl
345 ->expects($this->once())
346 ->method('getCmd')
347 ->willReturn('getResetMessageBoxHtml');
348
349 $this->ctrl
350 ->expects($this->once())
351 ->method('getLinkTarget')
352 ->with($this->isInstanceOf(\ilTermsOfServiceDocumentGUI::class), 'confirmReset')
353 ->willReturn('confirmReset');
354
355 $this->rbacsystem
356 ->expects($this->any())
357 ->method('checkAccess')
358 ->willReturn(true);
359
360 $buttonFactory = $this->getMockBuilder(\ILIAS\UI\Component\Button\Factory::class)->getMock();
361 $button = $this->getMockBuilder(\ILIAS\UI\Component\Button\Standard::class)->getMock();
362
363 $buttonFactory
364 ->expects($this->once())
365 ->method('standard')
366 ->with($this->isType('string'), $this->equalTo('confirmReset'))
367 ->willReturn($button);
368
369 $this->uiFactory
370 ->expects($this->once())
371 ->method('button')
372 ->willReturn($buttonFactory);
373
374 $messageBoxFactory = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\Factory::class)->getMock();
375 $info = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\MessageBox::class)->getMock();
376
377 $messageBoxFactory
378 ->expects($this->once())
379 ->method('info')
380 ->with($this->stringContains('Agreements never reset'))
381 ->willReturn($info);
382
383 $info
384 ->expects($this->once())
385 ->method('withButtons')
386 ->with($this->countOf(1));
387
388 $this->uiFactory
389 ->expects($this->once())
390 ->method('messageBox')
391 ->willReturn($messageBoxFactory);
392
393 $this->error
394 ->expects($this->never())
395 ->method('raiseError');
396
397 $this->uiRenderer
398 ->expects($this->atLeast(1))
399 ->method('render')
400 ->willReturn('');
401
402 $this->lng
403 ->expects($this->exactly(2))
404 ->method('txt')
405 ->willReturnOnConsecutiveCalls(
406 'Agreements never reset',
407 'Some button text'
408 );
409
410 $gui = new \ilTermsOfServiceDocumentGUI(
411 $this->tos,
412 $this->criterionTypeFactory,
413 $this->tpl,
414 $this->user,
415 $this->ctrl,
416 $this->lng,
417 $this->rbacsystem,
418 $this->error,
419 $this->log,
420 $this->toolbar,
421 $this->httpState,
422 $this->uiFactory,
423 $this->uiRenderer,
424 $this->fileSystems,
425 $this->fileUpload,
426 $this->tableDataProviderFactory,
427 $this->documentPurifier
428 );
429
430 $gui->executeCommand();
431 }

References $info, error(), Sabre\Event\once(), ilTermsOfServiceBaseTest\setGlobalVariable(), and user().

+ Here is the call graph for this function:

Field Documentation

◆ $criterionTypeFactory

ilTermsOfServiceDocumentGUITest::$criterionTypeFactory
protected

Definition at line 62 of file ilTermsOfServiceDocumentGUITest.php.

◆ $ctrl

ilTermsOfServiceDocumentGUITest::$ctrl
protected

Definition at line 26 of file ilTermsOfServiceDocumentGUITest.php.

◆ $documentPurifier

ilTermsOfServiceDocumentGUITest::$documentPurifier
protected

Definition at line 65 of file ilTermsOfServiceDocumentGUITest.php.

◆ $error

ilTermsOfServiceDocumentGUITest::$error
protected

Definition at line 35 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileSystems

ilTermsOfServiceDocumentGUITest::$fileSystems
protected

Definition at line 59 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileUpload

ilTermsOfServiceDocumentGUITest::$fileUpload
protected

Definition at line 56 of file ilTermsOfServiceDocumentGUITest.php.

◆ $httpState

ilTermsOfServiceDocumentGUITest::$httpState
protected

Definition at line 50 of file ilTermsOfServiceDocumentGUITest.php.

◆ $lng

ilTermsOfServiceDocumentGUITest::$lng
protected

Definition at line 29 of file ilTermsOfServiceDocumentGUITest.php.

◆ $log

ilTermsOfServiceDocumentGUITest::$log
protected

Definition at line 41 of file ilTermsOfServiceDocumentGUITest.php.

◆ $rbacsystem

ilTermsOfServiceDocumentGUITest::$rbacsystem
protected

Definition at line 32 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tableDataProviderFactory

ilTermsOfServiceDocumentGUITest::$tableDataProviderFactory
protected

Definition at line 17 of file ilTermsOfServiceDocumentGUITest.php.

◆ $toolbar

ilTermsOfServiceDocumentGUITest::$toolbar
protected

Definition at line 53 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tos

ilTermsOfServiceDocumentGUITest::$tos
protected

Definition at line 20 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tpl

ilTermsOfServiceDocumentGUITest::$tpl
protected

Definition at line 23 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiFactory

ilTermsOfServiceDocumentGUITest::$uiFactory
protected

Definition at line 44 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiRenderer

ilTermsOfServiceDocumentGUITest::$uiRenderer
protected

Definition at line 47 of file ilTermsOfServiceDocumentGUITest.php.

◆ $user

ilTermsOfServiceDocumentGUITest::$user
protected

Definition at line 38 of file ilTermsOfServiceDocumentGUITest.php.


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