ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 
ilRbacSystem $rbacsystem_mock
 
ilObjUser $user_mock
 
int $SYSTEM_FOLDER_ID
 
int $ROOT_FOLDER_ID
 

Detailed Description

Definition at line 26 of file ilServicesGlobalScreenTest.php.

Member Function Documentation

◆ setUp()

ilServicesGlobalScreenTest::setUp ( )
protected

Definition at line 42 of file ilServicesGlobalScreenTest.php.

References $DIC, ROOT_FOLDER_ID, and SYSTEM_FOLDER_ID.

42  : void
43  {
44  global $DIC;
45  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
46  $DIC = new Container();
47  if (!defined('SYSTEM_FOLDER_ID')) {
48  define('SYSTEM_FOLDER_ID', 42);
49  }
51  if (!defined('ROOT_FOLDER_ID')) {
52  define('ROOT_FOLDER_ID', 24);
53  }
55  }
const ROOT_FOLDER_ID
Definition: constants.php:32
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:22

◆ tearDown()

ilServicesGlobalScreenTest::tearDown ( )
protected

Definition at line 57 of file ilServicesGlobalScreenTest.php.

References $DIC, and $dic_backup.

57  : void
58  {
59  global $DIC;
60  $DIC = $this->dic_backup;
61  }
global $DIC
Definition: shib_login.php:22

◆ testAdminAccessFalse()

ilServicesGlobalScreenTest::testAdminAccessFalse ( )

Definition at line 80 of file ilServicesGlobalScreenTest.php.

References $DIC, and SYSTEM_FOLDER_ID.

80  : void
81  {
82  global $DIC;
83  $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
84  $class = new BasicAccessCheckClosures($DIC);
85 
86  $rbac_mock->expects($this->once())
87  ->method('checkAccess')
88  ->with('visible', $this->SYSTEM_FOLDER_ID)
89  ->willReturn(false);
90 
91  $this->assertFalse($class->hasAdministrationAccess()());
92  $this->assertFalse(
93  $class->hasAdministrationAccess()()
94  ); // second call to check caching, see expectation $this->once()
95  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:22

◆ testAdminAccessTrue()

ilServicesGlobalScreenTest::testAdminAccessTrue ( )

Definition at line 63 of file ilServicesGlobalScreenTest.php.

References $DIC, and SYSTEM_FOLDER_ID.

63  : void
64  {
65  global $DIC;
66  $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
67  $class = new BasicAccessCheckClosures($DIC);
68 
69  $rbac_mock->expects($this->once())
70  ->method('checkAccess')
71  ->with('visible', $this->SYSTEM_FOLDER_ID)
72  ->willReturn(true);
73 
74  $this->assertTrue($class->hasAdministrationAccess()());
75  $this->assertTrue(
76  $class->hasAdministrationAccess()()
77  ); // second call to check caching, see expectation $this->once()
78  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:22

◆ testAdminAcessTrueButWithClosure()

ilServicesGlobalScreenTest::testAdminAcessTrueButWithClosure ( )

Definition at line 97 of file ilServicesGlobalScreenTest.php.

References $DIC, and SYSTEM_FOLDER_ID.

97  : void
98  {
99  global $DIC;
100  $DIC['rbacsystem'] = $rbac_mock = $this->createMock(ilRbacSystem::class);
101  $class = new BasicAccessCheckClosures($DIC);
102 
103  $rbac_mock->expects($this->once())
104  ->method('checkAccess')
105  ->with('visible', $this->SYSTEM_FOLDER_ID)
106  ->willReturn(true);
107 
108  $closure_returning_false = fn(): bool => false;
109 
110  $this->assertTrue($class->hasAdministrationAccess()());
111  $this->assertFalse(
112  $class->hasAdministrationAccess($closure_returning_false)()
113  );
114  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:22

◆ testRepoAccessFalseLoggedIn()

ilServicesGlobalScreenTest::testRepoAccessFalseLoggedIn ( )

Definition at line 224 of file ilServicesGlobalScreenTest.php.

References $DIC, and ROOT_FOLDER_ID.

224  : void
225  {
226  global $DIC;
227 
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);
231 
232  $class = new BasicAccessCheckClosures($DIC);
233 
234  $user_mock->expects($this->once())
235  ->method('isAnonymous')
236  ->willReturn(false);
237 
238  $user_mock->expects($this->once())
239  ->method('getId')
240  ->willReturn(6);
241 
242  $settings_mock->expects($this->never())
243  ->method('get');
244 
245  $access_mock->expects($this->once())
246  ->method('checkAccess')
247  ->with('read', '', $this->ROOT_FOLDER_ID)
248  ->willReturn(false);
249 
250  $this->assertFalse($class->isRepositoryReadable()());
251  $this->assertFalse(
252  $class->isRepositoryReadable()()
253  ); // second call to check caching, see expectation $this->once()
254  $this->assertFalse(
255  $class->isRepositoryReadable(fn(): bool => true)()
256  );
257  $this->assertFalse(
258  $class->isRepositoryReadable(fn(): bool => false)()
259  );
260  }
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: shib_login.php:22

◆ testRepoAccessTrueLoggedIn()

ilServicesGlobalScreenTest::testRepoAccessTrueLoggedIn ( )

Definition at line 186 of file ilServicesGlobalScreenTest.php.

References $DIC, and ROOT_FOLDER_ID.

186  : void
187  {
188  global $DIC;
189 
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);
193 
194  $class = new BasicAccessCheckClosures($DIC);
195 
196  $user_mock->expects($this->once())
197  ->method('isAnonymous')
198  ->willReturn(false);
199 
200  $user_mock->expects($this->once())
201  ->method('getId')
202  ->willReturn(6);
203 
204  $settings_mock->expects($this->never())
205  ->method('get');
206 
207  $access_mock->expects($this->once())
208  ->method('checkAccess')
209  ->with('read', '', $this->ROOT_FOLDER_ID)
210  ->willReturn(true);
211 
212  $this->assertTrue($class->isRepositoryReadable()());
213  $this->assertTrue(
214  $class->isRepositoryReadable()()
215  ); // second call to check caching, see expectation $this->once()
216  $this->assertTrue(
217  $class->isRepositoryReadable(fn(): bool => true)()
218  );
219  $this->assertFalse(
220  $class->isRepositoryReadable(fn(): bool => false)()
221  );
222  }
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: shib_login.php:22

◆ testRepoAccessTrueNotLoggedInNoPublicSection()

ilServicesGlobalScreenTest::testRepoAccessTrueNotLoggedInNoPublicSection ( )

Definition at line 152 of file ilServicesGlobalScreenTest.php.

References $DIC.

152  : void
153  {
154  global $DIC;
155 
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);
159 
160  $class = new BasicAccessCheckClosures($DIC);
161 
162  $user_mock->expects($this->once())
163  ->method('isAnonymous')
164  ->willReturn(true);
165 
166  $settings_mock->expects($this->once())
167  ->method('get')
168  ->with('pub_section')
169  ->willReturn('0');
170 
171  $access_mock->expects($this->never())
172  ->method('checkAccessOfUser');
173 
174  $this->assertFalse($class->isRepositoryReadable()());
175  $this->assertFalse(
176  $class->isRepositoryReadable()()
177  ); // second call to check caching, see expectation $this->once()
178  $this->assertFalse(
179  $class->isRepositoryReadable(fn(): bool => true)()
180  );
181  $this->assertFalse(
182  $class->isRepositoryReadable(fn(): bool => false)()
183  );
184  }
global $DIC
Definition: shib_login.php:22

◆ testRepoAccessTrueNotLoggedInPublicSection()

ilServicesGlobalScreenTest::testRepoAccessTrueNotLoggedInPublicSection ( )

Definition at line 116 of file ilServicesGlobalScreenTest.php.

References $DIC, and ROOT_FOLDER_ID.

116  : void
117  {
118  global $DIC;
119 
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);
123 
124  $class = new BasicAccessCheckClosures($DIC);
125 
126  $user_mock->expects($this->once())
127  ->method('isAnonymous')
128  ->willReturn(true);
129 
130  $settings_mock->expects($this->once())
131  ->method('get')
132  ->with('pub_section')
133  ->willReturn('1');
134 
135  $access_mock->expects($this->once())
136  ->method('checkAccessOfUser')
137  ->with($this->isType('integer'), 'read', '', $this->ROOT_FOLDER_ID)
138  ->willReturn(true);
139 
140  $this->assertTrue($class->isRepositoryReadable()());
141  $this->assertTrue(
142  $class->isRepositoryReadable()()
143  ); // second call to check caching, see expectation $this->once()
144  $this->assertTrue(
145  $class->isRepositoryReadable(fn(): bool => true)()
146  );
147  $this->assertFalse(
148  $class->isRepositoryReadable(fn(): bool => false)()
149  );
150  }
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: shib_login.php:22

Field Documentation

◆ $dic_backup

Container ilServicesGlobalScreenTest::$dic_backup = null
private

Definition at line 28 of file ilServicesGlobalScreenTest.php.

Referenced by tearDown().

◆ $rbacsystem_mock

ilRbacSystem ilServicesGlobalScreenTest::$rbacsystem_mock
private

Definition at line 33 of file ilServicesGlobalScreenTest.php.

◆ $ROOT_FOLDER_ID

int ilServicesGlobalScreenTest::$ROOT_FOLDER_ID
private

Definition at line 40 of file ilServicesGlobalScreenTest.php.

◆ $SYSTEM_FOLDER_ID

int ilServicesGlobalScreenTest::$SYSTEM_FOLDER_ID
private

Definition at line 39 of file ilServicesGlobalScreenTest.php.

◆ $user_mock

ilObjUser ilServicesGlobalScreenTest::$user_mock
private

Definition at line 38 of file ilServicesGlobalScreenTest.php.


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