ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilServicesGlobalScreenTest Class Reference
+ Inheritance diagram for ilServicesGlobalScreenTest:
+ Collaboration diagram for ilServicesGlobalScreenTest:

Public Member Functions

 testAdminAccessTrue ()
 
 testAdminAccessFalse ()
 
 testAdminAcessTrueButWithClosure ()
 
 testRepoAccessTrueNotLoggedInPublicSection ()
 
 testRepoAccessTrueNotLoggedInNoPublicSection ()
 
 testRepoAccessTrueLoggedIn ()
 
 testRepoAccessFalseLoggedIn ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Attributes

Container $dic_backup = null
 
int $SYSTEM_FOLDER_ID
 
int $ROOT_FOLDER_ID
 

Detailed Description

Definition at line 25 of file ilServicesGlobalScreenTest.php.

Member Function Documentation

◆ setUp()

ilServicesGlobalScreenTest::setUp ( )
protected

Definition at line 31 of file ilServicesGlobalScreenTest.php.

31 : void
32 {
33 global $DIC;
34 $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
35 $DIC = new Container();
36 if (!defined('SYSTEM_FOLDER_ID')) {
37 define('SYSTEM_FOLDER_ID', 42);
38 }
40 if (!defined('ROOT_FOLDER_ID')) {
41 define('ROOT_FOLDER_ID', 24);
42 }
44 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: shib_login.php:26

References $DIC, ROOT_FOLDER_ID, and SYSTEM_FOLDER_ID.

◆ tearDown()

ilServicesGlobalScreenTest::tearDown ( )
protected

Definition at line 46 of file ilServicesGlobalScreenTest.php.

46 : void
47 {
48 global $DIC;
50 }

References $DIC, and $dic_backup.

◆ testAdminAccessFalse()

ilServicesGlobalScreenTest::testAdminAccessFalse ( )

Definition at line 69 of file ilServicesGlobalScreenTest.php.

69 : void
70 {
71 global $DIC;
72 $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
73 $class = new BasicAccessCheckClosures($DIC);
74
75 $rbac_mock->expects($this->once())
76 ->method('checkAccess')
77 ->with('visible', $this->SYSTEM_FOLDER_ID)
78 ->willReturn(false);
79
80 $this->assertFalse($class->hasAdministrationAccess()());
81 $this->assertFalse(
82 $class->hasAdministrationAccess()()
83 ); // second call to check caching, see expectation $this->once()
84 }

References $DIC, and SYSTEM_FOLDER_ID.

◆ testAdminAccessTrue()

ilServicesGlobalScreenTest::testAdminAccessTrue ( )

Definition at line 52 of file ilServicesGlobalScreenTest.php.

52 : void
53 {
54 global $DIC;
55 $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
56 $class = new BasicAccessCheckClosures($DIC);
57
58 $rbac_mock->expects($this->once())
59 ->method('checkAccess')
60 ->with('visible', $this->SYSTEM_FOLDER_ID)
61 ->willReturn(true);
62
63 $this->assertTrue($class->hasAdministrationAccess()());
64 $this->assertTrue(
65 $class->hasAdministrationAccess()()
66 ); // second call to check caching, see expectation $this->once()
67 }

References $DIC, and SYSTEM_FOLDER_ID.

◆ testAdminAcessTrueButWithClosure()

ilServicesGlobalScreenTest::testAdminAcessTrueButWithClosure ( )

Definition at line 86 of file ilServicesGlobalScreenTest.php.

86 : void
87 {
88 global $DIC;
89 $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
90 $class = new BasicAccessCheckClosures($DIC);
91
92 $rbac_mock->expects($this->once())
93 ->method('checkAccess')
94 ->with('visible', $this->SYSTEM_FOLDER_ID)
95 ->willReturn(true);
96
97 $closure_returning_false = fn(): bool => false;
98
99 $this->assertTrue($class->hasAdministrationAccess()());
100 $this->assertFalse(
101 $class->hasAdministrationAccess($closure_returning_false)()
102 );
103 }

References $DIC, and SYSTEM_FOLDER_ID.

◆ testRepoAccessFalseLoggedIn()

ilServicesGlobalScreenTest::testRepoAccessFalseLoggedIn ( )

Definition at line 213 of file ilServicesGlobalScreenTest.php.

213 : void
214 {
215 global $DIC;
216
217 $DIC['ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
218 $DIC['ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
219 $DIC['ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
220
221 $class = new BasicAccessCheckClosures($DIC);
222
223 $user_mock->expects($this->once())
224 ->method('isAnonymous')
225 ->willReturn(false);
226
227 $user_mock->expects($this->once())
228 ->method('getId')
229 ->willReturn(6);
230
231 $settings_mock->expects($this->never())
232 ->method('get');
233
234 $access_mock->expects($this->once())
235 ->method('checkAccess')
236 ->with('read', '', $this->ROOT_FOLDER_ID)
237 ->willReturn(false);
238
239 $this->assertFalse($class->isRepositoryReadable()());
240 $this->assertFalse(
241 $class->isRepositoryReadable()()
242 ); // second call to check caching, see expectation $this->once()
243 $this->assertFalse(
244 $class->isRepositoryReadable(fn(): bool => true)()
245 );
246 $this->assertFalse(
247 $class->isRepositoryReadable(fn(): bool => false)()
248 );
249 }

References $DIC, and ROOT_FOLDER_ID.

◆ testRepoAccessTrueLoggedIn()

ilServicesGlobalScreenTest::testRepoAccessTrueLoggedIn ( )

Definition at line 175 of file ilServicesGlobalScreenTest.php.

175 : void
176 {
177 global $DIC;
178
179 $DIC['ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
180 $DIC['ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
181 $DIC['ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
182
183 $class = new BasicAccessCheckClosures($DIC);
184
185 $user_mock->expects($this->once())
186 ->method('isAnonymous')
187 ->willReturn(false);
188
189 $user_mock->expects($this->once())
190 ->method('getId')
191 ->willReturn(6);
192
193 $settings_mock->expects($this->never())
194 ->method('get');
195
196 $access_mock->expects($this->once())
197 ->method('checkAccess')
198 ->with('read', '', $this->ROOT_FOLDER_ID)
199 ->willReturn(true);
200
201 $this->assertTrue($class->isRepositoryReadable()());
202 $this->assertTrue(
203 $class->isRepositoryReadable()()
204 ); // second call to check caching, see expectation $this->once()
205 $this->assertTrue(
206 $class->isRepositoryReadable(fn(): bool => true)()
207 );
208 $this->assertFalse(
209 $class->isRepositoryReadable(fn(): bool => false)()
210 );
211 }

References $DIC, and ROOT_FOLDER_ID.

◆ testRepoAccessTrueNotLoggedInNoPublicSection()

ilServicesGlobalScreenTest::testRepoAccessTrueNotLoggedInNoPublicSection ( )

Definition at line 141 of file ilServicesGlobalScreenTest.php.

141 : void
142 {
143 global $DIC;
144
145 $DIC['ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
146 $DIC['ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
147 $DIC['ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
148
149 $class = new BasicAccessCheckClosures($DIC);
150
151 $user_mock->expects($this->once())
152 ->method('isAnonymous')
153 ->willReturn(true);
154
155 $settings_mock->expects($this->once())
156 ->method('get')
157 ->with('pub_section')
158 ->willReturn('0');
159
160 $access_mock->expects($this->never())
161 ->method('checkAccessOfUser');
162
163 $this->assertFalse($class->isRepositoryReadable()());
164 $this->assertFalse(
165 $class->isRepositoryReadable()()
166 ); // second call to check caching, see expectation $this->once()
167 $this->assertFalse(
168 $class->isRepositoryReadable(fn(): bool => true)()
169 );
170 $this->assertFalse(
171 $class->isRepositoryReadable(fn(): bool => false)()
172 );
173 }

References $DIC.

◆ testRepoAccessTrueNotLoggedInPublicSection()

ilServicesGlobalScreenTest::testRepoAccessTrueNotLoggedInPublicSection ( )

Definition at line 105 of file ilServicesGlobalScreenTest.php.

105 : void
106 {
107 global $DIC;
108
109 $DIC['ilUser'] = $user_mock = $this->createMock(ilObjUser::class);
110 $DIC['ilSetting'] = $settings_mock = $this->createMock(ilSetting::class);
111 $DIC['ilAccess'] = $access_mock = $this->createMock(ilAccessHandler::class);
112
113 $class = new BasicAccessCheckClosures($DIC);
114
115 $user_mock->expects($this->once())
116 ->method('isAnonymous')
117 ->willReturn(true);
118
119 $settings_mock->expects($this->once())
120 ->method('get')
121 ->with('pub_section')
122 ->willReturn('1');
123
124 $access_mock->expects($this->once())
125 ->method('checkAccessOfUser')
126 ->with($this->isType('integer'), 'read', '', $this->ROOT_FOLDER_ID)
127 ->willReturn(true);
128
129 $this->assertTrue($class->isRepositoryReadable()());
130 $this->assertTrue(
131 $class->isRepositoryReadable()()
132 ); // second call to check caching, see expectation $this->once()
133 $this->assertTrue(
134 $class->isRepositoryReadable(fn(): bool => true)()
135 );
136 $this->assertFalse(
137 $class->isRepositoryReadable(fn(): bool => false)()
138 );
139 }

References $DIC, and ROOT_FOLDER_ID.

Field Documentation

◆ $dic_backup

Container ilServicesGlobalScreenTest::$dic_backup = null
private

Definition at line 27 of file ilServicesGlobalScreenTest.php.

Referenced by tearDown().

◆ $ROOT_FOLDER_ID

int ilServicesGlobalScreenTest::$ROOT_FOLDER_ID
private

Definition at line 29 of file ilServicesGlobalScreenTest.php.

◆ $SYSTEM_FOLDER_ID

int ilServicesGlobalScreenTest::$SYSTEM_FOLDER_ID
private

Definition at line 28 of file ilServicesGlobalScreenTest.php.


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