19 declare(strict_types=1);
73 protected function setUp(): void
77 $this->tos = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
78 $this->criterionTypeFactory = $this->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)->disableOriginalConstructor()->getMock();
79 $this->tpl = $this->getMockBuilder(ilGlobalTemplateInterface::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();
103 [
'default_____read', [
false]],
104 [
'confirmReset', [
true,
false]],
105 [
'reset', [
true,
false]],
106 [
'saveAddDocumentForm', [
true,
false]],
107 [
'showAddDocumentForm', [
true,
false]],
108 [
'saveEditDocumentForm', [
true,
false]],
109 [
'showEditDocumentForm', [
true,
false]],
110 [
'deleteDocuments', [
true,
false]],
111 [
'saveDocumentSorting', [
true,
false]],
112 [
'showAttachCriterionForm', [
true,
false]],
113 [
'saveAttachCriterionForm', [
true,
false]],
114 [
'showChangeCriterionForm', [
true,
false]],
115 [
'saveChangeCriterionForm', [
true,
false]],
116 [
'detachCriterionAssignment', [
true,
false]]
128 ->expects($this->once())
130 ->willReturn($command);
132 $accessResultCounter = 0;
134 ->expects($this->exactly(count($accessResults)))
135 ->method(
'checkAccess')
136 ->willReturnCallback(
function () use ($accessResults, &$accessResultCounter) {
137 $result = $accessResults[$accessResultCounter];
139 $accessResultCounter++;
145 ->method(
'raiseError')
146 ->willThrowException(
new ilException(
'no_permission'));
150 $this->criterionTypeFactory,
164 $this->tableDataProviderFactory,
165 $this->documentPurifier,
169 $this->expectException(ilException::class);
171 $gui->executeCommand();
179 $lastResetDate = $this->getMockBuilder(ilDate::class)
180 ->disableOriginalConstructor()
185 $lastResetDate->setDate($date->getTimestamp(),
IL_CAL_UNIX);
190 'seconds' => (
int) $date->format(
's'),
191 'minutes' => (
int) $date->format(
'i'),
192 'hours' => (
int) $date->format(
'G'),
193 'mday' => (
int) $date->format(
'j'),
194 'wday' => (
int) $date->format(
'w'),
195 'mon' => (
int) $date->format(
'n'),
196 'year' => (
int) $date->format(
'Y'),
197 'yday' => (
int) $date->format(
'z'),
198 'weekday' => $date->format(
'l'),
199 'month' => $date->format(
'F'),
200 'isoday' => (
int) $date->format(
'N')
208 ->method(
'getLastResetDate')
209 ->willReturn($lastResetDate);
212 ->expects($this->once())
214 ->willReturn(
'getResetMessageBoxHtml');
217 ->expects($this->once())
218 ->method(
'getLinkTarget')
219 ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class),
'confirmReset')
220 ->willReturn(
'confirmReset');
223 ->method(
'checkAccess')
227 $button = $this->getMockBuilder(Standard::class)->getMock();
230 ->expects($this->once())
232 ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
233 ->willReturn($button);
236 ->expects($this->once())
238 ->willReturn($buttonFactory);
241 $info = $this->getMockBuilder(MessageBox::class)->getMock();
244 ->expects($this->once())
246 ->with($this->stringContains(
'Some date:'))
250 ->expects($this->once())
251 ->method(
'withButtons')
252 ->with($this->countOf(1));
255 ->expects($this->once())
256 ->method(
'messageBox')
257 ->willReturn($messageBoxFactory);
260 ->expects($this->never())
261 ->method(
'raiseError');
264 ->expects($this->atLeast(1))
269 ->expects($this->exactly(2))
271 ->willReturnOnConsecutiveCalls(
278 $this->criterionTypeFactory,
292 $this->tableDataProviderFactory,
293 $this->documentPurifier,
297 $gui->executeCommand();
305 $lastResetDate = $this->getMockBuilder(ilDate::class)
306 ->disableOriginalConstructor()
317 ->method(
'getLastResetDate')
318 ->willReturn($lastResetDate);
321 ->expects($this->once())
323 ->willReturn(
'getResetMessageBoxHtml');
326 ->expects($this->once())
327 ->method(
'getLinkTarget')
328 ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class),
'confirmReset')
329 ->willReturn(
'confirmReset');
332 ->method(
'checkAccess')
336 $button = $this->getMockBuilder(Standard::class)->getMock();
339 ->expects($this->once())
341 ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
342 ->willReturn($button);
345 ->expects($this->once())
347 ->willReturn($buttonFactory);
350 $info = $this->getMockBuilder(MessageBox::class)->getMock();
353 ->expects($this->once())
355 ->with($this->stringContains(
'Agreements never reset'))
359 ->expects($this->once())
360 ->method(
'withButtons')
361 ->with($this->countOf(1));
364 ->expects($this->once())
365 ->method(
'messageBox')
366 ->willReturn($messageBoxFactory);
369 ->expects($this->never())
370 ->method(
'raiseError');
373 ->expects($this->atLeast(1))
378 ->expects($this->exactly(2))
380 ->willReturnOnConsecutiveCalls(
381 'Agreements never reset',
387 $this->criterionTypeFactory,
401 $this->tableDataProviderFactory,
402 $this->documentPurifier,
406 $gui->executeCommand();
Class ilTermsOfServiceDocumentGUITest.
Interface GlobalHttpState.
An entity that renders components to a string output.
ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing(string $command, array $accessResults)
commandProvider
setGlobalVariable(string $name, $value)
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilHtmlPurifierInterface $documentPurifier
testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
ilTermsOfServiceTableDataProviderFactory $tableDataProviderFactory
Class ilTermsOfServiceBaseTest.
Interface for html sanitizing functionality.
Class ilTermsOfServiceTableDataProviderFactory.
GlobalHttpState $httpState
testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
Error Handling & global info handling uses PEAR error class.
Class ilTermsOfServiceDocumentGUI.
Class ilObjTermsOfService.
ilGlobalTemplateInterface $tpl
Interface ilTermsOfServiceCriterionTypeFactoryInterface.