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

Class ilTermsOfServiceDocumentGUITest. More...

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

Public Member Functions

 setUp ()
 
 commandProvider ()
 
 testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing (string $command, array $accessResults)
 commandProvider 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 ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 

Detailed Description

Member Function Documentation

◆ commandProvider()

ilTermsOfServiceDocumentGUITest::commandProvider ( )
Returns
string[]

Definition at line 99 of file ilTermsOfServiceDocumentGUITest.php.

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

◆ setUp()

ilTermsOfServiceDocumentGUITest::setUp ( )
Exceptions
ReflectionException

Definition at line 73 of file ilTermsOfServiceDocumentGUITest.php.

References 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(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();
94  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing()

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

commandProvider

Parameters
string$command
bool[]$accessResults

Definition at line 124 of file ilTermsOfServiceDocumentGUITest.php.

References $result, and user().

124  : void
125  {
126  $this->ctrl
127  ->expects($this->once())
128  ->method('getCmd')
129  ->willReturn($command);
130 
131  $accessResultCounter = 0;
132  $this->rbacsystem
133  ->expects($this->exactly(count($accessResults)))
134  ->method('checkAccess')
135  ->willReturnCallback(function () use ($accessResults, &$accessResultCounter) {
136  $result = $accessResults[$accessResultCounter];
137 
138  $accessResultCounter++;
139 
140  return $result;
141  });
142 
143  $this->error
144  ->expects($this->any())
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  );
167 
168  $this->expectException(ilException::class);
169 
170  $gui->executeCommand();
171  }
$result
user()
Definition: user.php:4
Class ilTermsOfServiceDocumentGUI.
+ Here is the call graph for this function:

◆ testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )
Exceptions
ReflectionException

Definition at line 176 of file ilTermsOfServiceDocumentGUITest.php.

References IL_CAL_UNIX, ilTermsOfServiceBaseTest\setGlobalVariable(), and user().

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

◆ testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()

ilTermsOfServiceDocumentGUITest::testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce ( )
Exceptions
ReflectionException

Definition at line 308 of file ilTermsOfServiceDocumentGUITest.php.

References ilTermsOfServiceBaseTest\setGlobalVariable(), and user().

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

Field Documentation

◆ $criterionTypeFactory

ilTermsOfServiceDocumentGUITest::$criterionTypeFactory
protected

Definition at line 65 of file ilTermsOfServiceDocumentGUITest.php.

◆ $ctrl

ilTermsOfServiceDocumentGUITest::$ctrl
protected

Definition at line 29 of file ilTermsOfServiceDocumentGUITest.php.

◆ $documentPurifier

ilTermsOfServiceDocumentGUITest::$documentPurifier
protected

Definition at line 68 of file ilTermsOfServiceDocumentGUITest.php.

◆ $error

ilTermsOfServiceDocumentGUITest::$error
protected

Definition at line 38 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileSystems

ilTermsOfServiceDocumentGUITest::$fileSystems
protected

Definition at line 62 of file ilTermsOfServiceDocumentGUITest.php.

◆ $fileUpload

ilTermsOfServiceDocumentGUITest::$fileUpload
protected

Definition at line 59 of file ilTermsOfServiceDocumentGUITest.php.

◆ $httpState

ilTermsOfServiceDocumentGUITest::$httpState
protected

Definition at line 53 of file ilTermsOfServiceDocumentGUITest.php.

◆ $lng

ilTermsOfServiceDocumentGUITest::$lng
protected

Definition at line 32 of file ilTermsOfServiceDocumentGUITest.php.

◆ $log

ilTermsOfServiceDocumentGUITest::$log
protected

Definition at line 44 of file ilTermsOfServiceDocumentGUITest.php.

◆ $rbacsystem

ilTermsOfServiceDocumentGUITest::$rbacsystem
protected

Definition at line 35 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tableDataProviderFactory

ilTermsOfServiceDocumentGUITest::$tableDataProviderFactory
protected

Definition at line 20 of file ilTermsOfServiceDocumentGUITest.php.

◆ $toolbar

ilTermsOfServiceDocumentGUITest::$toolbar
protected

Definition at line 56 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tos

ilTermsOfServiceDocumentGUITest::$tos
protected

Definition at line 23 of file ilTermsOfServiceDocumentGUITest.php.

◆ $tpl

ilTermsOfServiceDocumentGUITest::$tpl
protected

Definition at line 26 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiFactory

ilTermsOfServiceDocumentGUITest::$uiFactory
protected

Definition at line 47 of file ilTermsOfServiceDocumentGUITest.php.

◆ $uiRenderer

ilTermsOfServiceDocumentGUITest::$uiRenderer
protected

Definition at line 50 of file ilTermsOfServiceDocumentGUITest.php.

◆ $user

ilTermsOfServiceDocumentGUITest::$user
protected

Definition at line 41 of file ilTermsOfServiceDocumentGUITest.php.


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