ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjChatroomAccessTest Class Reference

Class ilObjChatroomAccessTest. More...

+ Inheritance diagram for ilObjChatroomAccessTest:
+ Collaboration diagram for ilObjChatroomAccessTest:

Public Member Functions

 testInstanceOf ()
 
 test_getCommands ()
 
 test_checkGotoReturnFalse ()
 
 test_checkGotoReturnTrue ()
 
 test_checkGotoIssueWithTargetNotAString ()
 
 test_checkAccessReturnFalse ()
 
 test_checkAccessReturnTrueWithRbacAccess ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $access
 

Detailed Description

Member Function Documentation

◆ setUp()

ilObjChatroomAccessTest::setUp ( )
protected

Definition at line 15 of file class.ilObjChatroomAccessTest.php.

References defined.

16  {
17  if(defined('ILIAS_PHPUNIT_CONTEXT'))
18  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir(dirname(__FILE__));
25  chdir('../../../');
26  }
27 
28  require_once './Services/Administration/classes/class.ilSetting.php';
29  require_once './Modules/Chatroom/classes/class.ilObjChatroomAccess.php';
30  $this->access = new ilObjChatroomAccess();
31  }
Access class for chatroom objects.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ test_checkAccessReturnFalse()

ilObjChatroomAccessTest::test_checkAccessReturnFalse ( )

Definition at line 87 of file class.ilObjChatroomAccessTest.php.

References $GLOBALS, and array.

88  {
89  $userId = 1;
90  $refId = 99;
91  $GLOBALS['ilUser'] = $this->getMockBuilder('ilUser')->disableOriginalConstructor()->setMethods(
92  array('getId')
93  )->getMock();
94  $GLOBALS['ilUser']->expects($this->once())->method('getId')->will($this->returnValue($userId));
95 
96  $GLOBALS['ilDB'] = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(
97  array('quote', 'query', 'fetchAssoc')
98  )->getMock();
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))
103  );
104 
105  $GLOBALS['rbacsystem'] = $this->getMockBuilder('ilRbacSystem')->disableOriginalConstructor()->setMethods(
106  array('checkAccessOfUser')
107  )->getMock();
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));
113 
114  $this->assertFalse($this->access->_checkAccess('unused', 'unused', $refId, 'unused'));
115  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.

◆ test_checkAccessReturnTrueWithRbacAccess()

ilObjChatroomAccessTest::test_checkAccessReturnTrueWithRbacAccess ( )

Definition at line 117 of file class.ilObjChatroomAccessTest.php.

References $GLOBALS, and array.

118  {
119  $userId = 1;
120  $refId = 99;
121  $GLOBALS['ilUser'] = $this->getMockBuilder('ilUser')->disableOriginalConstructor()->setMethods(
122  array('getId')
123  )->getMock();
124  $GLOBALS['ilUser']->expects($this->once())->method('getId')->will($this->returnValue($userId));
125 
126  $GLOBALS['ilDB'] = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(
127  array('quote', 'query', 'fetchAssoc')
128  )->getMock();
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))
133  );
134 
135  $GLOBALS['rbacsystem'] = $this->getMockBuilder('ilRbacSystem')->disableOriginalConstructor()->setMethods(
136  array('checkAccessOfUser')
137  )->getMock();
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));
143 
144  $this->assertTrue($this->access->_checkAccess('unused', 'unused', $refId, 'unused'));
145  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.

◆ test_checkGotoIssueWithTargetNotAString()

ilObjChatroomAccessTest::test_checkGotoIssueWithTargetNotAString ( )

Definition at line 81 of file class.ilObjChatroomAccessTest.php.

References array.

82  {
83  $this->assertFalse($this->access->_checkGoto(array('chtr', '5')));
84  $this->assertFalse($this->access->_checkGoto(5));
85  }
Create styles array
The data for the language used.

◆ test_checkGotoReturnFalse()

ilObjChatroomAccessTest::test_checkGotoReturnFalse ( )

Definition at line 51 of file class.ilObjChatroomAccessTest.php.

References $GLOBALS, and array.

52  {
53  $GLOBALS['rbacsystem'] = $this->getMockBuilder('ilRbacSystem')->disableOriginalConstructor()->setMethods(
54  array('checkAccess',)
55  )->getMock();
56  $GLOBALS['rbacsystem']->expects($this->any())->method('checkAccess')->with(
57  $this->equalTo('read'),
58  $this->equalTo('1')
59  )->will($this->returnValue(false));
60 
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'));
67  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.

◆ test_checkGotoReturnTrue()

ilObjChatroomAccessTest::test_checkGotoReturnTrue ( )

Definition at line 69 of file class.ilObjChatroomAccessTest.php.

References $GLOBALS, and array.

70  {
71  $GLOBALS['rbacsystem'] = $this->getMockBuilder('ilRbacSystem')->disableOriginalConstructor()->setMethods(
72  array('checkAccess')
73  )->getMock();
74  $GLOBALS['rbacsystem']->expects($this->once())->method('checkAccess')->with(
75  $this->equalTo('read'),
76  $this->equalTo('5')
77  )->will($this->returnValue(true));
78  $this->assertTrue($this->access->_checkGoto('chtr_5'));
79  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.

◆ test_getCommands()

ilObjChatroomAccessTest::test_getCommands ( )

Definition at line 38 of file class.ilObjChatroomAccessTest.php.

References array.

39  {
40  $expected = array(
41  array("permission" => "read", "cmd" => "view", "lang_var" => "enter", "default" => true),
42  array("permission" => "write", "cmd" => "settings-general", "lang_var" => "settings"),
43  );
44 
45  $commands = $this->access->_getCommands();
46 
47  $this->assertInternalType("array", $commands);
48  $this->assertEquals($expected, $commands);
49  }
Create styles array
The data for the language used.

◆ testInstanceOf()

ilObjChatroomAccessTest::testInstanceOf ( )

Definition at line 33 of file class.ilObjChatroomAccessTest.php.

34  {
35  $this->assertInstanceOf('ilObjectAccess', $this->access);
36  }

Field Documentation

◆ $access

ilObjChatroomAccessTest::$access
protected

Definition at line 13 of file class.ilObjChatroomAccessTest.php.


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