ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjChatroomTest.php
Go to the documentation of this file.
1<?php
2
3require_once 'class.ilChatroomAbstractTest.php';
4
10{
11
15 protected $object;
16
17 protected function setUp()
18 {
19 parent::setUp(); // TODO: Change the autogenerated stub
20
21 require_once './Modules/Chatroom/classes/class.ilObjChatroom.php';
22
24
25 $this->object = $this->createMock(
26 'ilObjChatroom',
27 array('createDefaultRole')
28 );
29 }
30
31 public function testConstructor()
32 {
33 $this->assertInstanceOf('ilObjChatroom', $this->object);
34 }
35
37 {
38 $this->ilChatroomUserMock->expects($this->once())->method('getUserId')->will($this->returnValue(6));
39 $this->ilChatroomUserMock->expects($this->once())->method('getUsername')->will($this->returnValue('username'));
40
41 $userInfo = $this->object->getPersonalInformation($this->ilChatroomUserMock);
42
43 $this->assertInstanceOf('stdClass', $userInfo);
44 $this->assertEquals('username', $userInfo->username);
45 $this->assertEquals(6, $userInfo->id);
46 }
47
48 public function test_GetPublicRefId()
49 {
50 $this->assertEquals(0, $this->object->_getPublicRefId());
51 }
52
53 public function test_GetPublicObjId()
54 {
55 $this->createGlobalIlDBMock();
56
57 $query = 'SELECT object_id FROM chatroom_settings WHERE room_type=default';
58 $GLOBALS['ilDB']->expects($this->once())->method('query')->with($this->equalTo($query));
59 $GLOBALS['ilDB']->expects($this->once())->method('quote')->with($this->equalTo('default'))->will($this->returnValue('default'));
60 $GLOBALS['ilDB']->expects($this->once())->method('fetchAssoc')->will($this->returnValue(array('object_id' => '6')));
61
62 $this->assertEquals(6, $this->object->_getPublicObjId());
63 }
64
66 {
67 $this->createGlobalIlDBMock();
68
69 $query = 'SELECT object_id FROM chatroom_settings WHERE room_type=default';
70 $GLOBALS['ilDB']->expects($this->once())->method('query')->with($this->equalTo($query));
71 $GLOBALS['ilDB']->expects($this->once())->method('quote')->with($this->equalTo('default'))->will($this->returnValue('default'));
72 $GLOBALS['ilDB']->expects($this->once())->method('fetchAssoc')->will($this->returnValue(null));
73
74 $this->assertEquals(0, $this->object->_getPublicObjId());
75 }
76
77 public function testInitDefaultRoles()
78 {
79 //include_once './Services/AccessControl/classes/class.ilObjRole.php';
80 $this->backupStaticAttributes = true;
81 $this->object->expects($this->once())->method('createDefaultRole');
82 $this->assertEmpty($this->object->initDefaultRoles());
83 }
84}
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomAbstractTest.
Class ilObjChatroomTest.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query