ILIAS  release_8 Revision v8.23
ilTermsOfServiceDocumentGUITest Class Reference

Class ilTermsOfServiceDocumentGUITest. More...

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

Public Member Functions

 commandProvider ()
 
 testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing (string $command, array $accessResults)
 commandProvider More...
 
 testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ()
 
 testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ()
 

Protected Member Functions

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

Protected Attributes

ilTermsOfServiceTableDataProviderFactory $tableDataProviderFactory
 
ilObjTermsOfService $tos
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilRbacSystem $rbacsystem
 
ilErrorHandling $error
 
ilObjUser $user
 
ilLogger $log
 
Factory $uiFactory
 
Renderer $uiRenderer
 
GlobalHttpState $httpState
 
ilToolbarGUI $toolbar
 
FileUpload $fileUpload
 
Filesystems $fileSystems
 
ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
 
ilHtmlPurifierInterface $documentPurifier
 
Refinery $refinery
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ commandProvider()

ilTermsOfServiceDocumentGUITest::commandProvider ( )

Definition at line 100 of file ilTermsOfServiceDocumentGUITest.php.

100  : array
101  {
102  return [
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]]
117  ];
118  }

◆ setUp()

ilTermsOfServiceDocumentGUITest::setUp ( )
protected

Definition at line 73 of file ilTermsOfServiceDocumentGUITest.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

73  : void
74  {
75  parent::setUp();
76 
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();
94  $this->refinery = new ILIAS\Refinery\Factory(
95  new \ILIAS\Data\Factory(),
96  $this->lng
97  );
98  }
Class ChatMainBarProvider .
+ Here is the call graph for this function:

◆ testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing()

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

commandProvider

Parameters
string$command
bool[]$accessResults

Definition at line 125 of file ilTermsOfServiceDocumentGUITest.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

125  : void
126  {
127  $this->ctrl
128  ->expects($this->once())
129  ->method('getCmd')
130  ->willReturn($command);
131 
132  $accessResultCounter = 0;
133  $this->rbacsystem
134  ->expects($this->exactly(count($accessResults)))
135  ->method('checkAccess')
136  ->willReturnCallback(function () use ($accessResults, &$accessResultCounter) {
137  $result = $accessResults[$accessResultCounter];
138 
139  $accessResultCounter++;
140 
141  return $result;
142  });
143 
144  $this->error
145  ->method('raiseError')
146  ->willThrowException(new ilException('no_permission'));
147 
148  $gui = new ilTermsOfServiceDocumentGUI(
149  $this->tos,
150  $this->criterionTypeFactory,
151  $this->tpl,
152  $this->user,
153  $this->ctrl,
154  $this->lng,
155  $this->rbacsystem,
156  $this->error,
157  $this->log,
158  $this->toolbar,
159  $this->httpState,
160  $this->uiFactory,
161  $this->uiRenderer,
162  $this->fileSystems,
163  $this->fileUpload,
164  $this->tableDataProviderFactory,
165  $this->documentPurifier,
166  $this->refinery
167  );
168 
169  $this->expectException(ilException::class);
170 
171  $gui->executeCommand();
172  }
Class ilTermsOfServiceDocumentGUI.
+ Here is the call graph for this function:

◆ testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )

Definition at line 174 of file ilTermsOfServiceDocumentGUITest.php.

References ILIAS\Repository\ctrl(), IL_CAL_UNIX, ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilTermsOfServiceBaseTest\setGlobalVariable(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

174  : void
175  {
176  $this->setGlobalVariable('lng', clone $this->lng);
177  $this->setGlobalVariable('ilUser', clone $this->user);
178 
179  $lastResetDate = $this->getMockBuilder(ilDate::class)
180  ->disableOriginalConstructor()
181  ->getMock();
182 
183  $date = new DateTime();
184 
185  $lastResetDate->setDate($date->getTimestamp(), IL_CAL_UNIX);
186 
187  $lastResetDate
188  ->method('get')
189  ->willReturn([
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')
201  ]);
202 
203  $lastResetDate
204  ->method('isNull')
205  ->willReturn(true); // Required because of \ilDatePresentation static calls
206 
207  $this->tos
208  ->method('getLastResetDate')
209  ->willReturn($lastResetDate);
210 
211  $this->ctrl
212  ->expects($this->once())
213  ->method('getCmd')
214  ->willReturn('getResetMessageBoxHtml');
215 
216  $this->ctrl
217  ->expects($this->once())
218  ->method('getLinkTarget')
219  ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class), 'confirmReset')
220  ->willReturn('confirmReset');
221 
222  $this->rbacsystem
223  ->method('checkAccess')
224  ->willReturn(true);
225 
226  $buttonFactory = $this->getMockBuilder(\ILIAS\UI\Component\Button\Factory::class)->getMock();
227  $button = $this->getMockBuilder(Standard::class)->getMock();
228 
229  $buttonFactory
230  ->expects($this->once())
231  ->method('standard')
232  ->with($this->isType('string'), $this->equalTo('confirmReset'))
233  ->willReturn($button);
234 
235  $this->uiFactory
236  ->expects($this->once())
237  ->method('button')
238  ->willReturn($buttonFactory);
239 
240  $messageBoxFactory = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\Factory::class)->getMock();
241  $info = $this->getMockBuilder(MessageBox::class)->getMock();
242 
243  $messageBoxFactory
244  ->expects($this->once())
245  ->method('info')
246  ->with($this->stringContains('Some date:'))
247  ->willReturn($info);
248 
249  $info
250  ->expects($this->once())
251  ->method('withButtons')
252  ->with($this->countOf(1));
253 
254  $this->uiFactory
255  ->expects($this->once())
256  ->method('messageBox')
257  ->willReturn($messageBoxFactory);
258 
259  $this->error
260  ->expects($this->never())
261  ->method('raiseError');
262 
263  $this->uiRenderer
264  ->expects($this->atLeast(1))
265  ->method('render')
266  ->willReturn('');
267 
268  $this->lng
269  ->expects($this->exactly(2))
270  ->method('txt')
271  ->willReturnOnConsecutiveCalls(
272  'Some date: %s',
273  'Some button text'
274  );
275 
276  $gui = new ilTermsOfServiceDocumentGUI(
277  $this->tos,
278  $this->criterionTypeFactory,
279  $this->tpl,
280  $this->user,
281  $this->ctrl,
282  $this->lng,
283  $this->rbacsystem,
284  $this->error,
285  $this->log,
286  $this->toolbar,
287  $this->httpState,
288  $this->uiFactory,
289  $this->uiRenderer,
290  $this->fileSystems,
291  $this->fileUpload,
292  $this->tableDataProviderFactory,
293  $this->documentPurifier,
294  $this->refinery
295  );
296 
297  $gui->executeCommand();
298  }
Class Factory.
setGlobalVariable(string $name, $value)
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
const IL_CAL_UNIX
Class ilTermsOfServiceDocumentGUI.
+ Here is the call graph for this function:

◆ testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )

Definition at line 300 of file ilTermsOfServiceDocumentGUITest.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilTermsOfServiceBaseTest\setGlobalVariable(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

300  : void
301  {
302  $this->setGlobalVariable('lng', clone $this->lng);
303  $this->setGlobalVariable('ilUser', clone $this->user);
304 
305  $lastResetDate = $this->getMockBuilder(ilDate::class)
306  ->disableOriginalConstructor()
307  ->getMock();
308 
309  $lastResetDate
310  ->method('get')
311  ->willReturn(0);
312  $lastResetDate
313  ->method('isNull')
314  ->willReturn(true);
315 
316  $this->tos
317  ->method('getLastResetDate')
318  ->willReturn($lastResetDate);
319 
320  $this->ctrl
321  ->expects($this->once())
322  ->method('getCmd')
323  ->willReturn('getResetMessageBoxHtml');
324 
325  $this->ctrl
326  ->expects($this->once())
327  ->method('getLinkTarget')
328  ->with($this->isInstanceOf(ilTermsOfServiceDocumentGUI::class), 'confirmReset')
329  ->willReturn('confirmReset');
330 
331  $this->rbacsystem
332  ->method('checkAccess')
333  ->willReturn(true);
334 
335  $buttonFactory = $this->getMockBuilder(\ILIAS\UI\Component\Button\Factory::class)->getMock();
336  $button = $this->getMockBuilder(Standard::class)->getMock();
337 
338  $buttonFactory
339  ->expects($this->once())
340  ->method('standard')
341  ->with($this->isType('string'), $this->equalTo('confirmReset'))
342  ->willReturn($button);
343 
344  $this->uiFactory
345  ->expects($this->once())
346  ->method('button')
347  ->willReturn($buttonFactory);
348 
349  $messageBoxFactory = $this->getMockBuilder(\ILIAS\UI\Component\MessageBox\Factory::class)->getMock();
350  $info = $this->getMockBuilder(MessageBox::class)->getMock();
351 
352  $messageBoxFactory
353  ->expects($this->once())
354  ->method('info')
355  ->with($this->stringContains('Agreements never reset'))
356  ->willReturn($info);
357 
358  $info
359  ->expects($this->once())
360  ->method('withButtons')
361  ->with($this->countOf(1));
362 
363  $this->uiFactory
364  ->expects($this->once())
365  ->method('messageBox')
366  ->willReturn($messageBoxFactory);
367 
368  $this->error
369  ->expects($this->never())
370  ->method('raiseError');
371 
372  $this->uiRenderer
373  ->expects($this->atLeast(1))
374  ->method('render')
375  ->willReturn('');
376 
377  $this->lng
378  ->expects($this->exactly(2))
379  ->method('txt')
380  ->willReturnOnConsecutiveCalls(
381  'Agreements never reset',
382  'Some button text'
383  );
384 
385  $gui = new ilTermsOfServiceDocumentGUI(
386  $this->tos,
387  $this->criterionTypeFactory,
388  $this->tpl,
389  $this->user,
390  $this->ctrl,
391  $this->lng,
392  $this->rbacsystem,
393  $this->error,
394  $this->log,
395  $this->toolbar,
396  $this->httpState,
397  $this->uiFactory,
398  $this->uiRenderer,
399  $this->fileSystems,
400  $this->fileUpload,
401  $this->tableDataProviderFactory,
402  $this->documentPurifier,
403  $this->refinery
404  );
405 
406  $gui->executeCommand();
407  }
Class Factory.
setGlobalVariable(string $name, $value)
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
Class ilTermsOfServiceDocumentGUI.
+ Here is the call graph for this function:

Field Documentation

◆ $criterionTypeFactory

ilTermsOfServiceCriterionTypeFactoryInterface ilTermsOfServiceDocumentGUITest::$criterionTypeFactory
protected

Definition at line 68 of file ilTermsOfServiceDocumentGUITest.php.

◆ $ctrl

ilCtrlInterface ilTermsOfServiceDocumentGUITest::$ctrl
protected

Definition at line 44 of file ilTermsOfServiceDocumentGUITest.php.

◆ $documentPurifier

ilHtmlPurifierInterface ilTermsOfServiceDocumentGUITest::$documentPurifier
protected

Definition at line 70 of file ilTermsOfServiceDocumentGUITest.php.

◆ $error

ilErrorHandling ilTermsOfServiceDocumentGUITest::$error
protected

Definition at line 50 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileSystems

Filesystems ilTermsOfServiceDocumentGUITest::$fileSystems
protected

Definition at line 66 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileUpload

FileUpload ilTermsOfServiceDocumentGUITest::$fileUpload
protected

Definition at line 64 of file ilTermsOfServiceDocumentGUITest.php.

◆ $httpState

GlobalHttpState ilTermsOfServiceDocumentGUITest::$httpState
protected

Definition at line 60 of file ilTermsOfServiceDocumentGUITest.php.

◆ $lng

ilLanguage ilTermsOfServiceDocumentGUITest::$lng
protected

Definition at line 46 of file ilTermsOfServiceDocumentGUITest.php.

◆ $log

ilLogger ilTermsOfServiceDocumentGUITest::$log
protected

Definition at line 54 of file ilTermsOfServiceDocumentGUITest.php.

◆ $rbacsystem

ilRbacSystem ilTermsOfServiceDocumentGUITest::$rbacsystem
protected

Definition at line 48 of file ilTermsOfServiceDocumentGUITest.php.

◆ $refinery

Refinery ilTermsOfServiceDocumentGUITest::$refinery
protected

Definition at line 71 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tableDataProviderFactory

ilTermsOfServiceTableDataProviderFactory ilTermsOfServiceDocumentGUITest::$tableDataProviderFactory
protected

Definition at line 38 of file ilTermsOfServiceDocumentGUITest.php.

◆ $toolbar

ilToolbarGUI ilTermsOfServiceDocumentGUITest::$toolbar
protected

Definition at line 62 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tos

ilObjTermsOfService ilTermsOfServiceDocumentGUITest::$tos
protected

Definition at line 40 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tpl

ilGlobalTemplateInterface ilTermsOfServiceDocumentGUITest::$tpl
protected

Definition at line 42 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiFactory

Factory ilTermsOfServiceDocumentGUITest::$uiFactory
protected

Definition at line 56 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiRenderer

Renderer ilTermsOfServiceDocumentGUITest::$uiRenderer
protected

Definition at line 58 of file ilTermsOfServiceDocumentGUITest.php.

◆ $user

ilObjUser ilTermsOfServiceDocumentGUITest::$user
protected

Definition at line 52 of file ilTermsOfServiceDocumentGUITest.php.


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