ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomClearTaskTest.php
Go to the documentation of this file.
1<?php
2
3require_once dirname(__FILE__) . '/../class.ilChatroomAbstractTaskTest.php';
4
10{
11
15 protected $task;
16
17 protected function setUp()
18 {
19 parent::setUp();
20
21 require_once './Modules/Chatroom/classes/gui/class.ilChatroomClearGUI.php';
22 require_once './Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
23
24 $settings = new ilChatroomServerSettings();
25
30 $this->createilChatroomMock();
32 $this->createIlChatroomServerConnectorFileGetContentsMock(array('success' => true));
33 $this->createIlObjChatroomMock(15);
34 $this->createIlObjChatroomGUIMock($this->object);
36
37 $this->task = $this->getMock(
38 'ilChatroomClearGUI',
39 array('sendResponse', 'getRoomByObjectId', 'redirectIfNoPermission'),
40 array($this->gui)
41 );
42 }
43
44 public function testExecuteDefault()
45 {
46 $_REQUEST['sub'] = 0;
47
48 $this->task->expects($this->once())->method('redirectIfNoPermission')->with(
49 $this->equalTo('moderate')
50 );
51 $this->task->expects($this->any())->method('getRoomByObjectId')->will(
52 $this->returnValue($this->ilChatroomMock)
53 );
54 $this->createSendResponseMock($this->task, array(
55 'success' => true,
56 ));
57
58 $this->setExpectedException('Exception', 'Exit', 0);
59 $this->task->executeDefault(null);
60 }
61
63 {
64 $_REQUEST['sub'] = 0;
65
66 $this->task->expects($this->once())->method('redirectIfNoPermission')->with('moderate')->will($this->returnCallback(function ()
67 {
68 throw new Exception('Weak redirect on no Permission. Send just failure message instead', 1456351768);
69 }));
70
71 $this->setExpectedException('Exception', "", 1456351768);
72 $this->task->executeDefault(null);
73 }
74
76 {
77 $_REQUEST['sub'] = 0;
78
79 $this->task->expects($this->once())->method('redirectIfNoPermission')->with(
80 $this->equalTo('moderate')
81 );
82 $this->task->expects($this->any())->method('getRoomByObjectId')->will(
83 $this->returnValue(null)
84 );
85 $this->createSendResponseMock($this->task, array(
86 'success' => false,
87 'reason' => 'unkown room',
88 ));
89
90 $this->setExpectedException('Exception', 'Exit', 0);
91 $this->task->executeDefault(null);
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomAbstractTaskTest.
Class ilChatroomServerConnectorMock.
Class ilChatroomServerSettings.