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();
 
   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]]
 
  125            ->expects($this->any())
 
  130            ->expects($this->
once())
 
  132            ->willReturn($command);
 
  134        $accessResultCounter = 0;
 
  136            ->expects($this->exactly(count($accessResults)))
 
  137            ->method(
'checkAccess')
 
  138            ->willReturnCallback(
function () use ($accessResults, &$accessResultCounter) {
 
  139                $result = $accessResults[$accessResultCounter];
 
  141                $accessResultCounter++;
 
  147            ->expects($this->any())
 
  148            ->method(
'raiseError')
 
  149            ->willThrowException(
new \
ilException(
'no_permission'));
 
  151        $gui = new \ilTermsOfServiceDocumentGUI(
 
  153            $this->criterionTypeFactory,
 
  167            $this->tableDataProviderFactory,
 
  168            $this->documentPurifier
 
  173        $gui->executeCommand();
 
  185            ->expects($this->any())
 
  189        $lastResetDate = $this->getMockBuilder(\ilDate::class)
 
  190            ->disableOriginalConstructor()
 
  193        $date = new \DateTime();
 
  195        $lastResetDate->setDate($date->getTimestamp(), 
IL_CAL_UNIX);
 
  198            ->expects($this->any())
 
  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')
 
  215            ->expects($this->any())
 
  220            ->expects($this->any())
 
  221            ->method(
'getLastResetDate')
 
  222            ->willReturn($lastResetDate);
 
  225            ->expects($this->
once())
 
  227            ->willReturn(
'getResetMessageBoxHtml');
 
  230            ->expects($this->
once())
 
  231            ->method(
'getLinkTarget')
 
  232            ->with($this->isInstanceOf(\ilTermsOfServiceDocumentGUI::class), 
'confirmReset')
 
  233            ->willReturn(
'confirmReset');
 
  236            ->expects($this->any())
 
  237            ->method(
'checkAccess')
 
  240        $buttonFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Factory::class)->getMock();
 
  241        $button = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Standard::class)->getMock();
 
  244            ->expects($this->
once())
 
  246            ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
 
  247            ->willReturn($button);
 
  250            ->expects($this->
once())
 
  252            ->willReturn($buttonFactory);
 
  254        $messageBoxFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\Factory::class)->getMock();
 
  255        $info = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\MessageBox::class)->getMock();
 
  258            ->expects($this->
once())
 
  260            ->with($this->stringContains(
'Some date:'))
 
  264            ->expects($this->
once())
 
  265            ->method(
'withButtons')
 
  266            ->with($this->countOf(1));
 
  269            ->expects($this->
once())
 
  270            ->method(
'messageBox')
 
  271            ->willReturn($messageBoxFactory);
 
  274            ->expects($this->never())
 
  275            ->method(
'raiseError');
 
  278            ->expects($this->atLeast(1))
 
  283            ->expects($this->exactly(2))
 
  285            ->willReturnOnConsecutiveCalls(
 
  290        $gui = new \ilTermsOfServiceDocumentGUI(
 
  292            $this->criterionTypeFactory,
 
  306            $this->tableDataProviderFactory,
 
  307            $this->documentPurifier
 
  310        $gui->executeCommand();
 
  322            ->expects($this->any())
 
  326        $lastResetDate = $this->getMockBuilder(\ilDate::class)
 
  327            ->disableOriginalConstructor()
 
  331            ->expects($this->any())
 
  335            ->expects($this->any())
 
  340            ->expects($this->any())
 
  341            ->method(
'getLastResetDate')
 
  342            ->willReturn($lastResetDate);
 
  345            ->expects($this->
once())
 
  347            ->willReturn(
'getResetMessageBoxHtml');
 
  350            ->expects($this->
once())
 
  351            ->method(
'getLinkTarget')
 
  352            ->with($this->isInstanceOf(\ilTermsOfServiceDocumentGUI::class), 
'confirmReset')
 
  353            ->willReturn(
'confirmReset');
 
  356            ->expects($this->any())
 
  357            ->method(
'checkAccess')
 
  360        $buttonFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Factory::class)->getMock();
 
  361        $button = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Standard::class)->getMock();
 
  364            ->expects($this->
once())
 
  366            ->with($this->isType(
'string'), $this->equalTo(
'confirmReset'))
 
  367            ->willReturn($button);
 
  370            ->expects($this->
once())
 
  372            ->willReturn($buttonFactory);
 
  374        $messageBoxFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\Factory::class)->getMock();
 
  375        $info = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\MessageBox::class)->getMock();
 
  378            ->expects($this->
once())
 
  380            ->with($this->stringContains(
'Agreements never reset'))
 
  384            ->expects($this->
once())
 
  385            ->method(
'withButtons')
 
  386            ->with($this->countOf(1));
 
  389            ->expects($this->
once())
 
  390            ->method(
'messageBox')
 
  391            ->willReturn($messageBoxFactory);
 
  394            ->expects($this->never())
 
  395            ->method(
'raiseError');
 
  398            ->expects($this->atLeast(1))
 
  403            ->expects($this->exactly(2))
 
  405            ->willReturnOnConsecutiveCalls(
 
  406                'Agreements never reset',
 
  410        $gui = new \ilTermsOfServiceDocumentGUI(
 
  412            $this->criterionTypeFactory,
 
  426            $this->tableDataProviderFactory,
 
  427            $this->documentPurifier
 
  430        $gui->executeCommand();
 
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
Base class for ILIAS Exception handling.
Class ilTermsOfServiceBaseTest.
setGlobalVariable(string $name, $value)
assertException(string $exceptionClass)
Class ilTermsOfServiceDocumentGUITest.
testNoLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
testLastResetDateIsDisplayedInMessageBoxWhenAgreementsHaveBeenResetAtLeastOnce()
$tableDataProviderFactory
testAccessDeniedErrorIsRaisedWhenPermissionsAreMissing(string $command, array $accessResults)
@dataProvider commandProvider @expectedException \ilException
Interface GlobalHttpState.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.