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

Class ilChatroomTaskHandlerTest. More...

+ Inheritance diagram for ilChatroomTaskHandlerTest:
+ Collaboration diagram for ilChatroomTaskHandlerTest:

Public Member Functions

 testExecuteDefault ()
 
 testExecuteWithMethodExit ()
 
 testExecuteWithMethodNotExit ()
 
 testIsSuccessfull ()
 
 testCanModerate ($isOwnerOfPrivateRoomValue, $checkAccessValue, $result)
 @dataProvider canModerateDataProvider More...
 
 testExitIfNoRoomExists ()
 
 testExitIfNoRoomPermissionSuccess ()
 
 testExitIfNoRoomPermissionFails ()
 
 testRedirectIfNoPermission ()
 
 canModerateDataProvider ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilChatroomAbstractTaskTest
 setUp ()
 
 createGlobalIlLanguageMock ()
 
 createGlobalRbacSystemMock ()
 
 createGlobalRbacSystemCheckAccessMock ($permission, $result, $times=null)
 
 createGlobalIlCtrlMock ()
 
 createGlobalIlUserMock ()
 
 createIlObjChatroomGUIMock ($object)
 
 createIlObjChatroomGUIGetConnectorMock ($returnValue)
 
 createIlChatroomIsOwnerOfPrivateRoomMock ($userId, $subRoomId, $result)
 
 createIlChatroomUserGetUserIdMock ($userId)
 
 createIlChatroomServerConnectorMock ($settings)
 
 createIlChatroomServerConnectorFileGetContentsMock ($returnValue)
 
 createIlObjChatroomMock ($id)
 
 createSendResponseMock ($mock, $response)
 
- Protected Member Functions inherited from ilChatroomAbstractTest
 setUp ()
 
 createIlChatroomMock ()
 
 createIlChatroomUserMock ()
 
 createGlobalIlDBMock ()
 

Protected Attributes

 $handler
 
- Protected Attributes inherited from ilChatroomAbstractTaskTest
 $gui
 
 $ilChatroomServerConnectorMock
 
 $object
 
- Protected Attributes inherited from ilChatroomAbstractTest
 $ilChatroomMock
 
 $ilChatroomUserMock
 

Additional Inherited Members

- Data Fields inherited from ilChatroomAbstractTaskTest
const TEST_REF_ID = 99
 

Detailed Description

Member Function Documentation

◆ canModerateDataProvider()

ilChatroomTaskHandlerTest::canModerateDataProvider ( )
Returns
array

Definition at line 150 of file class.ilChatroomTaskHandlerTest.php.

151 {
152 return array(
153 array(true, true, true),
154 array(true, false, false),
155 array(false, true, false),
156 );
157 }

◆ setUp()

ilChatroomTaskHandlerTest::setUp ( )
protected

Reimplemented from ilChatroomAbstractTaskTest.

Definition at line 17 of file class.ilChatroomTaskHandlerTest.php.

18 {
19 parent::setUp();
20
25 $this->createIlObjChatroomMock(15);
26 $this->createIlObjChatroomGUIMock($this->object);
27
28 require_once './Modules/Chatroom/test/mocks/class.ilChatroomTaskHandlerMock.php';
29 $this->handler = new ilChatroomGUIHandlerMock($this->gui);
30 }

References ilChatroomAbstractTaskTest\createGlobalIlCtrlMock(), ilChatroomAbstractTaskTest\createGlobalIlLanguageMock(), ilChatroomAbstractTaskTest\createGlobalIlUserMock(), ilChatroomAbstractTaskTest\createGlobalRbacSystemMock(), ilChatroomAbstractTaskTest\createIlObjChatroomGUIMock(), and ilChatroomAbstractTaskTest\createIlObjChatroomMock().

+ Here is the call graph for this function:

◆ testCanModerate()

ilChatroomTaskHandlerTest::testCanModerate (   $isOwnerOfPrivateRoomValue,
  $checkAccessValue,
  $result 
)

@dataProvider canModerateDataProvider

Parameters
boolean$isOwnerOfPrivateRoomValue
boolean$checkAccessValue
boolean$result

Definition at line 68 of file class.ilChatroomTaskHandlerTest.php.

69 {
70 $userId = 6;
71 $subRoomId = 0;
72
73 $this->createIlChatroomMock();
74 $this->createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, $isOwnerOfPrivateRoomValue);
75 $this->createGlobalRbacSystemCheckAccessMock('moderate', $checkAccessValue);
76
77 $this->assertEquals($result, $this->handler->mockedCanModerate($this->ilChatroomMock, $subRoomId, $userId));
78 }
$result
createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, $result)
createGlobalRbacSystemCheckAccessMock($permission, $result, $times=null)

References $result, ilChatroomAbstractTaskTest\createGlobalRbacSystemCheckAccessMock(), ilChatroomAbstractTaskTest\createIlChatroomIsOwnerOfPrivateRoomMock(), and ilChatroomAbstractTest\createIlChatroomMock().

+ Here is the call graph for this function:

◆ testExecuteDefault()

ilChatroomTaskHandlerTest::testExecuteDefault ( )

Definition at line 32 of file class.ilChatroomTaskHandlerTest.php.

33 {
34 $this->assertEquals('default', $this->handler->executeDefault('default'));
35 }

◆ testExecuteWithMethodExit()

ilChatroomTaskHandlerTest::testExecuteWithMethodExit ( )

Definition at line 37 of file class.ilChatroomTaskHandlerTest.php.

38 {
39 $this->assertTrue($this->handler->execute('testFunc'));
40 }

◆ testExecuteWithMethodNotExit()

ilChatroomTaskHandlerTest::testExecuteWithMethodNotExit ( )

Definition at line 42 of file class.ilChatroomTaskHandlerTest.php.

43 {
44 $this->assertEquals('nonExistingFunc', $this->handler->execute('nonExistingFunc'));
45 }

◆ testExitIfNoRoomExists()

ilChatroomTaskHandlerTest::testExitIfNoRoomExists ( )

Definition at line 80 of file class.ilChatroomTaskHandlerTest.php.

81 {
82 $this->createIlChatroomMock();
83 $this->handler->mockedExitIfNoRoomExists($this->ilChatroomMock);
84
85 $this->setExpectedException(
86 'Exception',
87 json_encode(
88 array(
89 'success' => false,
90 'reason' => 'unkown room',
91 )
92 )
93 );
94 $this->handler->mockedExitIfNoRoomExists(null);
95 }

References ilChatroomAbstractTest\createIlChatroomMock().

+ Here is the call graph for this function:

◆ testExitIfNoRoomPermissionFails()

ilChatroomTaskHandlerTest::testExitIfNoRoomPermissionFails ( )

Definition at line 111 of file class.ilChatroomTaskHandlerTest.php.

112 {
113 $userId = 6;
114 $subRoomId = 0;
115
116 $this->createIlChatroomMock();
117 $this->createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, false);
119 $this->createIlChatroomUserGetUserIdMock($userId);
120 $this->createGlobalRbacSystemCheckAccessMock('moderate', false);
121
122 $this->setExpectedException(
123 'Exception',
124 json_encode(
125 array(
126 'success' => false,
127 'reason' => 'not owner of private room',
128 )
129 )
130 );
131
132 $this->handler->mockedExitIfNoRoomPermission($this->ilChatroomMock, $subRoomId, $this->ilChatroomUserMock);
133 }

References ilChatroomAbstractTaskTest\createGlobalRbacSystemCheckAccessMock(), ilChatroomAbstractTaskTest\createIlChatroomIsOwnerOfPrivateRoomMock(), ilChatroomAbstractTest\createIlChatroomMock(), ilChatroomAbstractTaskTest\createIlChatroomUserGetUserIdMock(), and ilChatroomAbstractTest\createIlChatroomUserMock().

+ Here is the call graph for this function:

◆ testExitIfNoRoomPermissionSuccess()

ilChatroomTaskHandlerTest::testExitIfNoRoomPermissionSuccess ( )

Definition at line 97 of file class.ilChatroomTaskHandlerTest.php.

98 {
99 $userId = 6;
100 $subRoomId = 0;
101
102 $this->createIlChatroomMock();
103 $this->createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, true);
105 $this->createIlChatroomUserGetUserIdMock($userId);
106 $this->createGlobalRbacSystemCheckAccessMock('moderate', true);
107
108 $this->handler->mockedExitIfNoRoomPermission($this->ilChatroomMock, $subRoomId, $this->ilChatroomUserMock);
109 }

References ilChatroomAbstractTaskTest\createGlobalRbacSystemCheckAccessMock(), ilChatroomAbstractTaskTest\createIlChatroomIsOwnerOfPrivateRoomMock(), ilChatroomAbstractTest\createIlChatroomMock(), ilChatroomAbstractTaskTest\createIlChatroomUserGetUserIdMock(), and ilChatroomAbstractTest\createIlChatroomUserMock().

+ Here is the call graph for this function:

◆ testIsSuccessfull()

ilChatroomTaskHandlerTest::testIsSuccessfull ( )

Definition at line 47 of file class.ilChatroomTaskHandlerTest.php.

48 {
49 $response = array('success' => true);
50 $this->assertTrue($this->handler->isSuccessful(json_encode($response)));
51
52 $response = array('success' => false);
53 $this->assertFalse($this->handler->isSuccessful(json_encode($response)));
54
55 $response = array('failed' => false);
56 $this->assertFalse($this->handler->isSuccessful(json_encode($response)));
57
58 $response = 'nonJson';
59 $this->assertFalse($this->handler->isSuccessful($response));
60 }

◆ testRedirectIfNoPermission()

ilChatroomTaskHandlerTest::testRedirectIfNoPermission ( )
Todo:
Weak static call

Definition at line 138 of file class.ilChatroomTaskHandlerTest.php.

139 {
140 $this->createGlobalRbacSystemCheckAccessMock('moderate', true, $this->at(0));
141 $this->createGlobalRbacSystemCheckAccessMock('user', false, $this->at(1));
142
143 $this->handler->redirectIfNoPermission('moderate');
144 $this->handler->redirectIfNoPermission('user');
145 }

References ilChatroomAbstractTaskTest\createGlobalRbacSystemCheckAccessMock().

+ Here is the call graph for this function:

Field Documentation

◆ $handler

ilChatroomTaskHandlerTest::$handler
protected

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


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