19 declare(strict_types=1);
36 [
'permission' =>
'read',
'cmd' =>
'view',
'lang_var' =>
'enter',
'default' =>
true],
37 [
'permission' =>
'write',
'cmd' =>
'settings-general',
'lang_var' =>
'settings'],
40 $commands = $this->access::_getCommands();
42 $this->assertIsArray($commands);
43 $this->assertSame($expected, $commands);
48 $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
51 $user->method(
'getId')->willReturn(6);
55 $chatroomSettings = $this->createMock(ilDBStatement::class);
57 ->method(
'fetchAssoc')
58 ->willReturnOnConsecutiveCalls(
60 'keyword' =>
'public_room_ref',
67 ->method(
'fetchAssoc')
68 ->willReturnCallback(
static function (
ilDBStatement $statement) {
74 ->with($this->stringContains(
"FROM settings WHERE module='chatroom'",
false))
75 ->willReturn($chatroomSettings);
78 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->onlyMethods(
79 [
'checkAccess',
'checkAccessOfUser']
81 $rbacsystem->method(
'checkAccess')->with(
82 $this->logicalOr($this->equalTo(
'read'), $this->equalTo(
'visible')),
85 $rbacsystem->method(
'checkAccessOfUser')->with(
87 $this->logicalOr($this->equalTo(
'read'), $this->equalTo(
'visible')),
93 $this->assertFalse($this->access::_checkGoto(
''));
94 $this->assertFalse($this->access::_checkGoto(
'chtr'));
95 $this->assertFalse($this->access::_checkGoto(
'chtr_'));
96 $this->assertFalse($this->access::_checkGoto(
'chtr_'));
97 $this->assertFalse($this->access::_checkGoto(
'chtr_test'));
98 $this->assertFalse($this->access::_checkGoto(
'chtr_1'));
103 $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
106 $user->method(
'getId')->willReturn(6);
110 $chatroomSettings = $this->createMock(ilDBStatement::class);
112 ->method(
'fetchAssoc')
113 ->willReturnOnConsecutiveCalls(
115 'keyword' =>
'public_room_ref',
122 ->method(
'fetchAssoc')
123 ->willReturnCallback(
static function (
ilDBStatement $statement) {
129 ->with($this->stringContains(
"FROM settings WHERE module='chatroom'",
false))
130 ->willReturn($chatroomSettings);
133 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->onlyMethods(
134 [
'checkAccess',
'checkAccessOfUser']
136 $rbacsystem->method(
'checkAccess')->with(
137 $this->logicalOr($this->equalTo(
'read'), $this->equalTo(
'visible'), $this->equalTo(
'write')),
140 $rbacsystem->method(
'checkAccessOfUser')->with(
142 $this->logicalOr($this->equalTo(
'read'), $this->equalTo(
'visible'), $this->equalTo(
'write')),
148 $this->assertTrue($this->access::_checkGoto(
'chtr_5'));
157 $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
160 $user->expects($this->once())->method(
'getId')->willReturn($userId);
164 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->onlyMethods(
165 [
'checkAccessOfUser']
167 $rbacsystem->expects($this->once())->method(
'checkAccessOfUser')->with(
168 $this->equalTo($userId),
169 $this->equalTo(
'write'),
171 )->willReturn(
false);
184 $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
187 $user->expects($this->once())->method(
'getId')->willReturn($userId);
191 $this->db->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
192 [
'keyword' =>
'chat_enabled',
'value' =>
'0'],
196 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->onlyMethods(
197 [
'checkAccessOfUser']
199 $rbacsystem->expects($this->once())->method(
'checkAccessOfUser')->with(
200 $this->equalTo($userId),
201 $this->equalTo(
'write'),
215 $cache = $settingsReflection->getProperty(
'settings_cache');
216 $cache->setAccessible(
true);
217 $cache->setValue($settingsReflection, []);
testCommandDefitionFullfilsExpectations()
Class ilChatroomAbstractTest.
testAccessChecksSucceed()
ilObjChatroomAccess $access
Access class for chatroom objects.
Class ilObjChatroomAccessTest.
setGlobalVariable(string $name, $value)