ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjChatroomAdminAccessTest.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
13  protected $adminAccess;
14 
18  protected $ilAccessMock;
19 
20  protected function setUp()
21  {
22  if(defined('ILIAS_PHPUNIT_CONTEXT'))
23  {
24  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
25  ilUnitUtil::performInitialisation();
26  }
27  else
28  {
29  chdir(dirname(__FILE__));
30  chdir('../../../');
31  }
32 
33  require_once './Services/AccessControl/classes/class.ilAccessHandler.php';
34  $this->ilAccessMock = $this->getMock('ilAccessHandler');
35  global $ilAccess;
36  $ilAccess = $this->ilAccessMock;
37 
38  require_once './Modules/Chatroom/classes/class.ilObjChatroomAdminAccess.php';
39  $this->adminAccess = new ilObjChatroomAdminAccess();
40  }
41 
42  public function testInstanceOf()
43  {
44  $this->assertInstanceOf('ilObjectAccess', $this->adminAccess);
45  }
46 
47  public function test_getCommands()
48  {
49  $expected = array(
50  array("permission" => "read", "cmd" => "view", "lang_var" => "enter", "default" => true),
51  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
52  array("permission" => "write", "cmd" => "versions", "lang_var" => "versions"),
53  );
54 
55  $commands = $this->adminAccess->_getCommands();
56 
57  $this->assertInternalType("array", $commands);
58  $this->assertEquals($expected, $commands);
59  }
60 
61  public function test_checkGotoReturnFalse()
62  {
63  $this->ilAccessMock->expects($this->any())->method('checkAccess')->with($this->equalTo('visible'), $this->equalTo(''), $this->equalTo('1'))->will($this->returnValue(false));
64 
65  $this->assertFalse($this->adminAccess->_checkGoto(''));
66  $this->assertFalse($this->adminAccess->_checkGoto('chtr'));
67  $this->assertFalse($this->adminAccess->_checkGoto('chtr_'));
68  $this->assertFalse($this->adminAccess->_checkGoto('chtr_'));
69  $this->assertFalse($this->adminAccess->_checkGoto('chtr_test'));
70  $this->assertFalse($this->adminAccess->_checkGoto('chtr_1'));
71  }
72 
73  public function test_checkGotoReturnTrue()
74  {
75  $this->ilAccessMock->expects($this->once())->method('checkAccess')->with($this->equalTo('visible'), $this->equalTo(''), $this->equalTo('5'))->will($this->returnValue(true));
76  $this->assertTrue($this->adminAccess->_checkGoto('chtr_5'));
77  }
78 
80  {
81  $this->assertFalse($this->adminAccess->_checkGoto(array('chtr', '5')));
82  $this->assertFalse($this->adminAccess->_checkGoto(5));
83  }
84 }
Class ilObjChatroomAdminAccess Access class for chatroom objects.
Class ilObjChatroomAdminAccessTest.
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27