19 declare(strict_types=1);
    42     protected function setUp(): void
    45         $this->dic_backup = is_object($DIC) ? clone 
$DIC : 
$DIC;
    47         if (!defined(
'SYSTEM_FOLDER_ID')) {
    48             define(
'SYSTEM_FOLDER_ID', 42);
    51         if (!defined(
'ROOT_FOLDER_ID')) {
    52             define(
'ROOT_FOLDER_ID', 24);
    66         $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
    69         $rbac_mock->expects($this->once())
    70                   ->method(
'checkAccess')
    74         $this->assertTrue($class->hasAdministrationAccess()());
    76             $class->hasAdministrationAccess()()
    83         $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
    86         $rbac_mock->expects($this->once())
    87                   ->method(
'checkAccess')
    91         $this->assertFalse($class->hasAdministrationAccess()());
    93             $class->hasAdministrationAccess()()
   100         $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
   103         $rbac_mock->expects($this->once())
   104                   ->method(
'checkAccess')
   108         $closure_returning_false = fn(): 
bool => 
false;
   110         $this->assertTrue($class->hasAdministrationAccess()());
   112             $class->hasAdministrationAccess($closure_returning_false)()
   120         $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
   121         $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
   122         $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
   126         $user_mock->expects($this->once())
   127                   ->method(
'isAnonymous')
   130         $settings_mock->expects($this->once())
   132                       ->with(
'pub_section')
   135         $access_mock->expects($this->once())
   136                     ->method(
'checkAccessOfUser')
   137                     ->with($this->isType(
'integer'), 
'read', 
'', $this->
ROOT_FOLDER_ID)
   140         $this->assertTrue($class->isRepositoryReadable()());
   142             $class->isRepositoryReadable()()
   145             $class->isRepositoryReadable(fn(): 
bool => 
true)()
   148             $class->isRepositoryReadable(fn(): 
bool => 
false)()
   156         $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
   157         $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
   158         $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
   162         $user_mock->expects($this->once())
   163                   ->method(
'isAnonymous')
   166         $settings_mock->expects($this->once())
   168                       ->with(
'pub_section')
   171         $access_mock->expects($this->never())
   172                     ->method(
'checkAccessOfUser');
   174         $this->assertFalse($class->isRepositoryReadable()());
   176             $class->isRepositoryReadable()()
   179             $class->isRepositoryReadable(fn(): 
bool => 
true)()
   182             $class->isRepositoryReadable(fn(): 
bool => 
false)()
   190         $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
   191         $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
   192         $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
   196         $user_mock->expects($this->once())
   197                   ->method(
'isAnonymous')
   200         $user_mock->expects($this->once())
   204         $settings_mock->expects($this->never())
   207         $access_mock->expects($this->once())
   208                     ->method(
'checkAccess')
   212         $this->assertTrue($class->isRepositoryReadable()());
   214             $class->isRepositoryReadable()()
   217             $class->isRepositoryReadable(fn(): 
bool => 
true)()
   220             $class->isRepositoryReadable(fn(): 
bool => 
false)()
   228         $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
   229         $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
   230         $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
   234         $user_mock->expects($this->once())
   235                   ->method(
'isAnonymous')
   238         $user_mock->expects($this->once())
   242         $settings_mock->expects($this->never())
   245         $access_mock->expects($this->once())
   246                     ->method(
'checkAccess')
   250         $this->assertFalse($class->isRepositoryReadable()());
   252             $class->isRepositoryReadable()()
   255             $class->isRepositoryReadable(fn(): 
bool => 
true)()
   258             $class->isRepositoryReadable(fn(): 
bool => 
false)()
 testRepoAccessFalseLoggedIn()
 
ilRbacSystem $rbacsystem_mock
 
Class BasicAccessCheckClosures. 
 
Customizing of pimple-DIC for ILIAS. 
 
testRepoAccessTrueNotLoggedInNoPublicSection()
 
testAdminAcessTrueButWithClosure()
 
testRepoAccessTrueLoggedIn()
 
testRepoAccessTrueNotLoggedInPublicSection()