19 declare(strict_types=1);
39 protected function setUp(): void
42 $this->dic_backup = is_object($DIC) ? clone
$DIC :
$DIC;
44 if (!defined(
'SYSTEM_FOLDER_ID')) {
45 define(
'SYSTEM_FOLDER_ID', 42);
48 if (!defined(
'ROOT_FOLDER_ID')) {
49 define(
'ROOT_FOLDER_ID', 24);
63 $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
66 $rbac_mock->expects($this->once())
67 ->method(
'checkAccess')
71 $this->assertTrue($class->hasAdministrationAccess()());
73 $class->hasAdministrationAccess()()
80 $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
83 $rbac_mock->expects($this->once())
84 ->method(
'checkAccess')
88 $this->assertFalse($class->hasAdministrationAccess()());
90 $class->hasAdministrationAccess()()
97 $DIC[
'rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
100 $rbac_mock->expects($this->once())
101 ->method(
'checkAccess')
105 $closure_returning_false =
function ():
bool {
109 $this->assertTrue($class->hasAdministrationAccess()());
111 $class->hasAdministrationAccess($closure_returning_false)()
119 $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
120 $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
121 $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
125 $user_mock->expects($this->once())
126 ->method(
'isAnonymous')
129 $settings_mock->expects($this->once())
131 ->with(
'pub_section')
134 $access_mock->expects($this->once())
135 ->method(
'checkAccessOfUser')
136 ->with($this->isType(
'integer'),
'read',
'', $this->
ROOT_FOLDER_ID)
139 $this->assertTrue($class->isRepositoryReadable()());
141 $class->isRepositoryReadable()()
144 $class->isRepositoryReadable(
function ():
bool {
149 $class->isRepositoryReadable(
function ():
bool {
159 $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
160 $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
161 $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
165 $user_mock->expects($this->once())
166 ->method(
'isAnonymous')
169 $settings_mock->expects($this->once())
171 ->with(
'pub_section')
174 $access_mock->expects($this->never())
175 ->method(
'checkAccessOfUser');
177 $this->assertFalse($class->isRepositoryReadable()());
179 $class->isRepositoryReadable()()
182 $class->isRepositoryReadable(
function ():
bool {
187 $class->isRepositoryReadable(
function ():
bool {
197 $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
198 $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
199 $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
203 $user_mock->expects($this->once())
204 ->method(
'isAnonymous')
207 $user_mock->expects($this->once())
211 $settings_mock->expects($this->never())
214 $access_mock->expects($this->once())
215 ->method(
'checkAccess')
219 $this->assertTrue($class->isRepositoryReadable()());
221 $class->isRepositoryReadable()()
224 $class->isRepositoryReadable(
function ():
bool {
229 $class->isRepositoryReadable(
function ():
bool {
239 $DIC[
'ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
240 $DIC[
'ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
241 $DIC[
'ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
245 $user_mock->expects($this->once())
246 ->method(
'isAnonymous')
249 $user_mock->expects($this->once())
253 $settings_mock->expects($this->never())
256 $access_mock->expects($this->once())
257 ->method(
'checkAccess')
261 $this->assertFalse($class->isRepositoryReadable()());
263 $class->isRepositoryReadable()()
266 $class->isRepositoryReadable(
function ():
bool {
271 $class->isRepositoryReadable(
function ():
bool {
testRepoAccessFalseLoggedIn()
ilRbacSystem $rbacsystem_mock
Class BasicAccessCheckClosures.
Customizing of pimple-DIC for ILIAS.
testRepoAccessTrueNotLoggedInNoPublicSection()
testAdminAcessTrueButWithClosure()
testRepoAccessTrueLoggedIn()
testRepoAccessTrueNotLoggedInPublicSection()