1 <?php declare(strict_types=1);
77 $this->tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
78 $this->criterionTypeFactory = $this->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)->disableOriginalConstructor()->getMock();
79 $this->tpl = $this->getMockBuilder(ilGlobalPageTemplate::class)->disableOriginalConstructor()->getMock();
80 $this->ctrl = $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->getMock();
81 $this->lng = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
82 $this->rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
83 $this->error = $this->getMockBuilder(ilErrorHandling::class)->disableOriginalConstructor()->getMock();
84 $this->
user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock();
85 $this->log = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
86 $this->toolbar = $this->getMockBuilder(ilToolbarGUI::class)->disableOriginalConstructor()->getMock();
87 $this->httpState = $this->getMockBuilder(GlobalHttpState::class)->getMock();
88 $this->uiFactory = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock();
89 $this->uiRenderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
90 $this->fileSystems = $this->getMockBuilder(Filesystems::class)->getMock();
91 $this->fileUpload = $this->getMockBuilder(FileUpload::class)->getMock();
92 $this->tableDataProviderFactory = $this->getMockBuilder(ilTermsOfServiceTableDataProviderFactory::class)->disableOriginalConstructor()->getMock();
93 $this->documentPurifier = $this->getMockBuilder(ilHtmlPurifierInterface::class)->getMock();
102 [
'default_____read', [
false]],
103 [
'confirmReset', [
true,
false]],
104 [
'reset', [
true,
false]],
105 [
'saveAddDocumentForm', [
true,
false]],
106 [
'showAddDocumentForm', [
true,
false]],
107 [
'saveEditDocumentForm', [
true,
false]],
108 [
'showEditDocumentForm', [
true,
false]],
109 [
'deleteDocuments', [
true,
false]],
110 [
'saveDocumentSorting', [
true,
false]],
111 [
'showAttachCriterionForm', [
true,
false]],
112 [
'saveAttachCriterionForm', [
true,
false]],
113 [
'showChangeCriterionForm', [
true,
false]],
114 [
'saveChangeCriterionForm', [
true,
false]],
115 [
'detachCriterionAssignment', [
true,
false]]
127 ->expects($this->once())
129 ->willReturn($command);
131 $accessResultCounter = 0;
133 ->expects($this->exactly(count($accessResults)))
134 ->method(
'checkAccess')
135 ->willReturnCallback(
function () use ($accessResults, &$accessResultCounter) {
136 $result = $accessResults[$accessResultCounter];
138 $accessResultCounter++;
144 ->expects($this->any())
145 ->method(
'raiseError')
146 ->willThrowException(
new ilException(
'no_permission'));
150 $this->criterionTypeFactory,
164 $this->tableDataProviderFactory,
165 $this->documentPurifier
168 $this->expectException(ilException::class);
170 $gui->executeCommand();
181 $lastResetDate = $this->getMockBuilder(ilDate::class)
182 ->disableOriginalConstructor()
185 $date =
new DateTime();
187 $lastResetDate->setDate($date->getTimestamp(),
IL_CAL_UNIX);
190 ->expects($this->any())
193 'seconds' => (
int) $date->format(
's'),
194 'minutes' => (int) $date->format(
'i'),
195 'hours' => (int) $date->format(
'G'),
196 'mday' => (int) $date->format(
'j'),
197 'wday' => (int) $date->format(
'w'),
198 'mon' => (int) $date->format(
'n'),
199 'year' => (int) $date->format(
'Y'),
200 'yday' => (int) $date->format(
'z'),
201 'weekday' => $date->format(
'l'),
202 'month' => $date->format(
'F'),
203 'isoday' => (int) $date->format(
'N')
207 ->expects($this->any())
212 ->expects($this->any())
213 ->method(
'getLastResetDate')
214 ->willReturn($lastResetDate);
217 ->expects($this->once())
219 ->willReturn(
'getResetMessageBoxHtml');
222 ->expects($this->once())
223 ->method(
'getLinkTarget')
224 ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class),
'confirmReset')
225 ->willReturn(
'confirmReset');
228 ->expects($this->any())
229 ->method(
'checkAccess')
233 $button = $this->getMockBuilder(Standard::class)->getMock();
236 ->expects($this->once())
238 ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
239 ->willReturn($button);
242 ->expects($this->once())
244 ->willReturn($buttonFactory);
247 $info = $this->getMockBuilder(MessageBox::class)->getMock();
250 ->expects($this->once())
252 ->with($this->stringContains(
'Some date:'))
256 ->expects($this->once())
257 ->method(
'withButtons')
258 ->with($this->countOf(1));
261 ->expects($this->once())
262 ->method(
'messageBox')
263 ->willReturn($messageBoxFactory);
266 ->expects($this->never())
267 ->method(
'raiseError');
270 ->expects($this->atLeast(1))
275 ->expects($this->exactly(2))
277 ->willReturnOnConsecutiveCalls(
284 $this->criterionTypeFactory,
298 $this->tableDataProviderFactory,
299 $this->documentPurifier
302 $gui->executeCommand();
313 $lastResetDate = $this->getMockBuilder(ilDate::class)
314 ->disableOriginalConstructor()
318 ->expects($this->any())
322 ->expects($this->any())
327 ->expects($this->any())
328 ->method(
'getLastResetDate')
329 ->willReturn($lastResetDate);
332 ->expects($this->once())
334 ->willReturn(
'getResetMessageBoxHtml');
337 ->expects($this->once())
338 ->method(
'getLinkTarget')
339 ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class),
'confirmReset')
340 ->willReturn(
'confirmReset');
343 ->expects($this->any())
344 ->method(
'checkAccess')
348 $button = $this->getMockBuilder(Standard::class)->getMock();
351 ->expects($this->once())
353 ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
354 ->willReturn($button);
357 ->expects($this->once())
359 ->willReturn($buttonFactory);
362 $info = $this->getMockBuilder(MessageBox::class)->getMock();
365 ->expects($this->once())
367 ->with($this->stringContains(
'Agreements never reset'))
371 ->expects($this->once())
372 ->method(
'withButtons')
373 ->with($this->countOf(1));
376 ->expects($this->once())
377 ->method(
'messageBox')
378 ->willReturn($messageBoxFactory);
381 ->expects($this->never())
382 ->method(
'raiseError');
385 ->expects($this->atLeast(1))
390 ->expects($this->exactly(2))
392 ->willReturnOnConsecutiveCalls(
393 'Agreements never reset',
399 $this->criterionTypeFactory,
413 $this->tableDataProviderFactory,
414 $this->documentPurifier
417 $gui->executeCommand();
Class ilTermsOfServiceDocumentGUITest.
testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing(string $command, array $accessResults)
commandProvider
setGlobalVariable(string $name, $value)
Class ChatMainBarProvider .
testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilTermsOfServiceBaseTest.
testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
Class ilTermsOfServiceDocumentGUI.
$tableDataProviderFactory