ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomAbstractTaskTest.php
Go to the documentation of this file.
1 <?php
2 
3 require_once 'class.ilChatroomAbstractTest.php';
4 
10 {
14  const TEST_REF_ID = 99;
15 
19  protected $gui;
20 
25 
29  protected $object;
30 
31  protected function setUp()
32  {
33  parent::setUp();
34 
35  if(!defined('ROOT_FOLDER_ID'))
36  {
37  define('ROOT_FOLDER_ID', time());
38  }
39  }
40 
41  protected function createGlobalIlLanguageMock()
42  {
43  require_once './Services/Language/classes/class.ilLanguage.php';
44  $GLOBALS['lng'] = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->setMethods(
45  array('loadLanguageModule', 'txt')
46  )->getMock();
47 
48  $GLOBALS['lng']->expects($this->any())->method('loadLanguageModule')->with($this->logicalOr($this->equalTo('chatroom'), $this->equalTo('meta')));
49  $GLOBALS['lng']->expects($this->any())->method('txt');
50 
51  return $GLOBALS['lng'];
52  }
53 
54  protected function createGlobalRbacSystemMock()
55  {
56  require_once './Services/AccessControl/classes/class.ilRbacSystem.php';
57  $GLOBALS['rbacsystem'] = $this->getMockBuilder('ilRbacSystem')->disableOriginalConstructor()->setMethods(
58  array('checkAccess')
59  )->getMock();
60 
61  return $GLOBALS['rbacsystem'];
62  }
63 
69  protected function createGlobalRbacSystemCheckAccessMock($permission, $result, $times = null)
70  {
71  if($times == null)
72  {
73  $times = $this->any();
74  }
75 
76  return $GLOBALS['rbacsystem']->expects($times)->method('checkAccess')->with($this->equalTo($permission))->will(
77  $this->returnValue($result)
78  );
79  }
80 
81  protected function createGlobalIlCtrlMock()
82  {
83  require_once './Services/UICore/classes/class.ilCtrl.php';
84 
85  $GLOBALS['ilCtrl'] = $this->getMockBuilder('ilCtrl')->disableOriginalConstructor()->setMethods(
86  array('setParameterByClass', 'redirectByClass', 'forwardCommand')
87  )->getMock();
88  $GLOBALS['ilCtrl']->expects($this->any())->method('setParameterByClass');
89  $GLOBALS['ilCtrl']->expects($this->any())->method('redirectByClass');
90 
91  return $GLOBALS['ilCtrl'];
92  }
93 
94  protected function createGlobalIlUserMock()
95  {
96  require_once 'Services/User/classes/class.ilObjUser.php';
97 
98  $GLOBALS['ilUser'] = $this->getMockBuilder('ilObjUser')->disableOriginalConstructor()->setMethods(
99  array()
100  )->getMock();
101 
102  return $GLOBALS['ilUser'];
103  }
104 
106  {
107  require_once './Modules/Chatroom/classes/class.ilObjChatroomGUI.php';
108 
109  $this->gui = $this->getMockBuilder('ilObjChatroomGUI')->disableOriginalConstructor()->disableArgumentCloning()->setMethods(
110  array('getRefId', 'getConnector', 'switchToVisibleMode')
111  )->getMock();
112  $this->gui->ref_id = self::TEST_REF_ID;
113  $this->gui->object = $object;
114 
115  return $this->gui;
116  }
117 
118  protected function createIlObjChatroomGUIGetConnectorMock($returnValue)
119  {
120  $this->gui->expects($this->any())->method('getConnector')->will($this->returnValue($returnValue));
121  }
122 
129  protected function createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, $result)
130  {
131  return $this->ilChatroomMock->expects($this->at(0))->method('isOwnerOfPrivateRoom')->with(
132  $this->equalTo($userId),
133  $this->equalTo($subRoomId)
134  )->will($this->returnValue($result));
135  }
136 
137  protected function createIlChatroomUserGetUserIdMock($userId)
138  {
139  return $this->ilChatroomUserMock->expects($this->any())->method('getUserId')->will($this->returnValue($userId));
140  }
141 
146  protected function createIlChatroomServerConnectorMock($settings)
147  {
148  require_once './Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
149 
150  $this->ilChatroomServerConnectorMock = $this->getMockBuilder('ilChatroomServerConnector')->setConstructorArgs(
151  array($settings)
152  )->setMethods(array('file_get_contents'))->getMock();
153 
155  }
156 
157  protected function createIlChatroomServerConnectorFileGetContentsMock($returnValue)
158  {
159  return $this->ilChatroomServerConnectorMock->expects($this->any())->method('file_get_contents')->will(
160  $this->returnValue($returnValue)
161  );
162  }
163 
164  protected function createIlObjChatroomMock($id)
165  {
166  require_once './Modules/Chatroom/classes/class.ilObjChatroom.php';
167 
168  $this->object = $this->getMockBuilder('ilObjChatroom')->disableOriginalConstructor()->setMethods(
169  array('getId')
170  )->getMock();
171  $this->object->expects($this->any())->method('getId')->will($this->returnValue($id));
172 
173  return $this->object;
174  }
175 
176  protected function createSendResponseMock($mock, $response)
177  {
178  $mock->expects($this->once())->method('sendResponse')->with(
179  $this->equalTo($response)
180  )->will(
181  $this->returnCallback(
182  function ()
183  {
184  throw new Exception('Exit', 0);
185  }
186  )
187  );
188  }
189 }
$result
Class ilChatroomAbstractTest.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class ilChatroomAbstractTaskTest.
createIlChatroomIsOwnerOfPrivateRoomMock($userId, $subRoomId, $result)
createGlobalRbacSystemCheckAccessMock($permission, $result, $times=null)
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
Class ilChatroomServerConnectorMock.