17 if (defined(
'ILIAS_PHPUNIT_CONTEXT')) {
18 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
19 ilUnitUtil::performInitialisation();
21 chdir(dirname(__FILE__));
25 require_once
'./Services/Administration/classes/class.ilSetting.php';
26 require_once
'./Modules/Chatroom/classes/class.ilObjChatroomAccess.php';
32 $this->assertInstanceOf(
'ilObjectAccess', $this->access);
38 array(
"permission" =>
"read",
"cmd" =>
"view",
"lang_var" =>
"enter",
"default" =>
true),
39 array(
"permission" =>
"write",
"cmd" =>
"settings-general",
"lang_var" =>
"settings"),
42 $commands = $this->access->_getCommands();
44 $this->assertInternalType(
"array", $commands);
45 $this->assertEquals($expected, $commands);
50 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
53 $GLOBALS[
'rbacsystem']->expects($this->any())->method(
'checkAccess')->with(
54 $this->equalTo(
'read'),
56 )->will($this->returnValue(
false));
58 $this->assertFalse($this->access->_checkGoto(
''));
59 $this->assertFalse($this->access->_checkGoto(
'chtr'));
60 $this->assertFalse($this->access->_checkGoto(
'chtr_'));
61 $this->assertFalse($this->access->_checkGoto(
'chtr_'));
62 $this->assertFalse($this->access->_checkGoto(
'chtr_test'));
63 $this->assertFalse($this->access->_checkGoto(
'chtr_1'));
68 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
71 $GLOBALS[
'rbacsystem']->expects($this->
once())->method(
'checkAccess')->with(
72 $this->equalTo(
'read'),
74 )->will($this->returnValue(
true));
75 $this->assertTrue($this->access->_checkGoto(
'chtr_5'));
80 $this->assertFalse($this->access->_checkGoto(array(
'chtr',
'5')));
81 $this->assertFalse($this->access->_checkGoto(5));
88 $GLOBALS[
'ilUser'] = $this->getMockBuilder(
'ilUser')->disableOriginalConstructor()->setMethods(
91 $GLOBALS[
'ilUser']->expects($this->
once())->method(
'getId')->will($this->returnValue($userId));
93 $GLOBALS[
'ilDB'] = $this->getMockBuilder(
'ilDBMySQL')->disableOriginalConstructor()->setMethods(
94 array(
'quote',
'query',
'fetchAssoc')
96 $GLOBALS[
'ilDB']->expects($this->any())->method(
'quote');
97 $GLOBALS[
'ilDB']->expects($this->any())->method(
'query');
98 $GLOBALS[
'ilDB']->expects($this->at(0))->method(
'fetchAssoc')->will(
99 $this->returnValue(array(
'keyword' =>
'chat_enabled',
'value' =>
false))
102 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
103 array(
'checkAccessOfUser')
105 $GLOBALS[
'rbacsystem']->expects($this->
once())->method(
'checkAccessOfUser')->with(
106 $this->equalTo($userId),
107 $this->equalTo(
'write'),
108 $this->equalTo($refId)
109 )->will($this->returnValue(
false));
111 $this->assertFalse($this->access->_checkAccess(
'unused',
'unused', $refId,
'unused'));
118 $GLOBALS[
'ilUser'] = $this->getMockBuilder(
'ilUser')->disableOriginalConstructor()->setMethods(
121 $GLOBALS[
'ilUser']->expects($this->
once())->method(
'getId')->will($this->returnValue($userId));
123 $GLOBALS[
'ilDB'] = $this->getMockBuilder(
'ilDBMySQL')->disableOriginalConstructor()->setMethods(
124 array(
'quote',
'query',
'fetchAssoc')
126 $GLOBALS[
'ilDB']->expects($this->any())->method(
'quote');
127 $GLOBALS[
'ilDB']->expects($this->any())->method(
'query');
128 $GLOBALS[
'ilDB']->expects($this->any())->method(
'fetchAssoc')->will(
129 $this->returnValue(array(
'keyword' =>
'chat_enabled',
'value' =>
false))
132 $GLOBALS[
'rbacsystem'] = $this->getMockBuilder(
'ilRbacSystem')->disableOriginalConstructor()->setMethods(
133 array(
'checkAccessOfUser')
135 $GLOBALS[
'rbacsystem']->expects($this->
once())->method(
'checkAccessOfUser')->with(
136 $this->equalTo($userId),
137 $this->equalTo(
'write'),
138 $this->equalTo($refId)
139 )->will($this->returnValue(
true));
141 $this->assertTrue($this->access->_checkAccess(
'unused',
'unused', $refId,
'unused'));
test_checkAccessReturnFalse()
test_checkGotoReturnTrue()
Access class for chatroom objects.
test_checkGotoReturnFalse()
test_checkAccessReturnTrueWithRbacAccess()
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Class ilObjChatroomAccessTest.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
test_checkGotoIssueWithTargetNotAString()