17 if(
defined(
'ILIAS_PHPUNIT_CONTEXT'))
19 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
20 ilUnitUtil::performInitialisation();
24 chdir(dirname(__FILE__));
28 require_once
'./Services/Administration/classes/class.ilSetting.php';
29 require_once
'./Modules/Chatroom/classes/class.ilObjChatroomAccess.php';
35 $this->assertInstanceOf(
'ilObjectAccess', $this->access);
41 array(
"permission" =>
"read",
"cmd" =>
"view",
"lang_var" =>
"enter",
"default" =>
true),
42 array(
"permission" =>
"write",
"cmd" =>
"settings-general",
"lang_var" =>
"settings"),
45 $commands = $this->access->_getCommands();
47 $this->assertInternalType(
"array", $commands);
48 $this->assertEquals($expected, $commands);
53 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
56 $GLOBALS[
'rbacsystem']->expects($this->any())->method(
'checkAccess')->with(
57 $this->equalTo(
'read'),
59 )->will($this->returnValue(
false));
61 $this->assertFalse($this->access->_checkGoto(
''));
62 $this->assertFalse($this->access->_checkGoto(
'chtr'));
63 $this->assertFalse($this->access->_checkGoto(
'chtr_'));
64 $this->assertFalse($this->access->_checkGoto(
'chtr_'));
65 $this->assertFalse($this->access->_checkGoto(
'chtr_test'));
66 $this->assertFalse($this->access->_checkGoto(
'chtr_1'));
71 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
74 $GLOBALS[
'rbacsystem']->expects($this->once())->method(
'checkAccess')->with(
75 $this->equalTo(
'read'),
77 )->will($this->returnValue(
true));
78 $this->assertTrue($this->access->_checkGoto(
'chtr_5'));
83 $this->assertFalse($this->access->_checkGoto(
array(
'chtr',
'5')));
84 $this->assertFalse($this->access->_checkGoto(5));
91 $GLOBALS[
'ilUser'] = $this->getMockBuilder(
'ilUser')->disableOriginalConstructor()->setMethods(
94 $GLOBALS[
'ilUser']->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
96 $GLOBALS[
'ilDB'] = $this->getMockBuilder(
'ilDBMySQL')->disableOriginalConstructor()->setMethods(
97 array(
'quote',
'query',
'fetchAssoc')
99 $GLOBALS[
'ilDB']->expects($this->any())->method(
'quote');
100 $GLOBALS[
'ilDB']->expects($this->any())->method(
'query');
101 $GLOBALS[
'ilDB']->expects($this->at(0))->method(
'fetchAssoc')->will(
102 $this->returnValue(
array(
'keyword' =>
'chat_enabled',
'value' =>
false))
105 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
106 array(
'checkAccessOfUser')
108 $GLOBALS[
'rbacsystem']->expects($this->once())->method(
'checkAccessOfUser')->with(
109 $this->equalTo($userId),
110 $this->equalTo(
'write'),
111 $this->equalTo($refId)
112 )->will($this->returnValue(
false));
114 $this->assertFalse($this->access->_checkAccess(
'unused',
'unused', $refId,
'unused'));
121 $GLOBALS[
'ilUser'] = $this->getMockBuilder(
'ilUser')->disableOriginalConstructor()->setMethods(
124 $GLOBALS[
'ilUser']->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
126 $GLOBALS[
'ilDB'] = $this->getMockBuilder(
'ilDBMySQL')->disableOriginalConstructor()->setMethods(
127 array(
'quote',
'query',
'fetchAssoc')
129 $GLOBALS[
'ilDB']->expects($this->any())->method(
'quote');
130 $GLOBALS[
'ilDB']->expects($this->any())->method(
'query');
131 $GLOBALS[
'ilDB']->expects($this->any())->method(
'fetchAssoc')->will(
132 $this->returnValue(
array(
'keyword' =>
'chat_enabled',
'value' =>
false))
135 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
136 array(
'checkAccessOfUser')
138 $GLOBALS[
'rbacsystem']->expects($this->once())->method(
'checkAccessOfUser')->with(
139 $this->equalTo($userId),
140 $this->equalTo(
'write'),
141 $this->equalTo($refId)
142 )->will($this->returnValue(
true));
144 $this->assertTrue($this->access->_checkAccess(
'unused',
'unused', $refId,
'unused'));
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
test_checkAccessReturnFalse()
test_checkGotoReturnTrue()
Access class for chatroom objects.
test_checkGotoReturnFalse()
test_checkAccessReturnTrueWithRbacAccess()
Class ilObjChatroomAccessTest.
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
test_checkGotoIssueWithTargetNotAString()