ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRBACTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  protected $backupGlobals = FALSE;
36 
37  protected function setUp()
38  {
39  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
40  ilUnitUtil::performInitialisation();
41  }
42 
48  public function testRbacFA()
49  {
50  global $rbacreview,$rbacadmin;
51 
52  // Non empty
53  $non_empty = $rbacreview->filterEmptyRoleFolders(array(8));
54  $this->assertEquals($non_empty,array(8));
55 
56  // Empty
57  $empty = $rbacreview->filterEmptyRoleFolders(array(1));
58  $this->assertEquals($empty,array());
59 
60  // Protected
61  $rbacadmin->setProtected(1,4,'y');
62  $prot = $rbacreview->isProtected(8,4);
63  $this->assertEquals($prot,true);
64  $rbacadmin->setProtected(1,4,'n');
65  $prot = $rbacreview->isProtected(8,4);
66  $this->assertEquals($prot,false);
67 
68  $rbacreview->getRoleListByObject(8);
69  $rbacreview->getAssignableRoles();
70 
71  // Child roles
72  $child1 = $rbacreview->getAssignableRolesInSubtree(8);
73  $child2 = $rbacreview->getAssignableChildRoles(8);
74  $this->assertEquals($child1,$child2);
75 
76  $ass = $rbacreview->isAssignable(4,8);
77  $this->assertEquals($ass,true);
78 
79  $roles = $rbacreview->getRolesOfRoleFolder(8);
80  $rbacreview->__getAllRoleFolderIds();
81 
82  $rbacreview->getLinkedRolesOfRoleFolder(8);
83 
84  $obj = $rbacreview->getObjectOfRole(4);
85  $this->assertEquals(9,$obj);
86 
87  $rbacreview->getRolesForIDs(array(4),false);
88  }
89 
93  public function testRbacUA()
94  {
95  global $rbacreview,$rbacadmin;
96 
97  $obj = ilUtil::_getObjectsByOperations('crs','join');
98 
99  $rbacreview->assignedUsers(4);
100  $rbacreview->assignedRoles(6);
101  }
102 
108  public function testRbacTA()
109  {
110  global $rbacreview,$rbacadmin;
111 
112  $sess_ops = $rbacreview->getOperationsOnTypeString('sess');
113 
114  $rbacadmin->assignOperationToObject($rbacreview->getTypeId('sess'),'7');
115  //$new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
116  //$this->assertEquals(array_merge($sess_ops,array(7)),$new_sess_ops);
117 
118  $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId('sess'),'7');
119  $new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
120  $this->assertEquals($sess_ops,$new_sess_ops);
121  }
122 
126  public function testRbacPA()
127  {
128  global $rbacreview,$rbacadmin;
129 
130  $sess_ops = $rbacreview->getOperationsOnTypeString('cat');
131 
132  $rbacadmin->revokePermission(1,4);
133  $rbacadmin->grantPermission(4,array(2,3),1);
134 
135  }
136 
142  public function testConditions()
143  {
144  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
145 
148 
149  $handler = new ilConditionHandler();
150  $handler->setTargetRefId(99999);
151  $handler->setTargetObjId(99998);
152  $handler->setTargetType('xxx');
153  $handler->setTriggerRefId(99997);
154  $handler->setTriggerObjId(99996);
155  $handler->setTriggerType('yyy');
156  $handler->setReferenceHandlingType(0);
157  $handler->enableAutomaticValidation(false);
158  $suc = $handler->storeCondition();
159  $this->assertEquals($suc,true);
160 
161  $suc = $handler->checkExists();
162  $this->assertEquals($suc,false);
163 
164  $suc = $handler->delete(99999);
165  $this->assertEquals($suc,true);
166 
167  // syntax check
168  $handler->deleteByObjId(-1);
169  $handler->deleteCondition(-1);
173  }
174 
175  public function testCache()
176  {
177  include_once './Services/AccessControl/classes/class.ilAccessHandler.php';
178 
179  $handler = new ilAccessHandler();
180  $handler->setResults(array(1,2,3));
181  $handler->storeCache();
182  $handler->readCache();
183  $res = $handler->getResults();
184 
185  $this->assertEquals(array(1,2,3),$res);
186  }
187 
188 
189 }
190 ?>