ILIAS  Release_4_4_x_branch Revision 61816
 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 
49  public function testRbacFA()
50  {
51  global $rbacreview,$rbacadmin;
52 
53  // Non empty
54  $non_empty = $rbacreview->filterEmptyRoleFolders(array(8));
55  $this->assertEquals($non_empty,array(8));
56 
57  // Empty
58  $empty = $rbacreview->filterEmptyRoleFolders(array(1));
59  $this->assertEquals($empty,array());
60 
61  // Protected
62  $rbacadmin->setProtected(1,4,'y');
63  $prot = $rbacreview->isProtected(8,4);
64  $this->assertEquals($prot,true);
65  $rbacadmin->setProtected(1,4,'n');
66  $prot = $rbacreview->isProtected(8,4);
67  $this->assertEquals($prot,false);
68 
69  $rbacreview->getRoleListByObject(8);
70  $rbacreview->getAssignableRoles();
71 
72 
73  $ass = $rbacreview->isAssignable(4,8);
74  $this->assertEquals($ass,true);
75 
76  $roles = $rbacreview->getRolesOfRoleFolder(8);
77  $rbacreview->__getAllRoleFolderIds();
78 
79  $rbacreview->getLinkedRolesOfRoleFolder(8);
80 
81  $obj = $rbacreview->getObjectOfRole(4);
82  $this->assertEquals(9,$obj);
83 
84  $rbacreview->getRolesForIDs(array(4),false);
85  }
86 
91  public function testRbacUA()
92  {
93  global $rbacreview,$rbacadmin;
94 
95  $obj = ilUtil::_getObjectsByOperations('crs','join');
96 
97  $rbacreview->assignedUsers(4);
98  $rbacreview->assignedRoles(6);
99  }
100 
107  public function testRbacTA()
108  {
109  global $rbacreview,$rbacadmin;
110 
111  $sess_ops = $rbacreview->getOperationsOnTypeString('sess');
112 
113  $rbacadmin->assignOperationToObject($rbacreview->getTypeId('sess'),'7');
114  //$new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
115  //$this->assertEquals(array_merge($sess_ops,array(7)),$new_sess_ops);
116 
117  $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId('sess'),'7');
118  $new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
119  $this->assertEquals($sess_ops,$new_sess_ops);
120  }
121 
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 
143  public function testConditions()
144  {
145  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
146 
149 
150  $handler = new ilConditionHandler();
151  $handler->setTargetRefId(99999);
152  $handler->setTargetObjId(99998);
153  $handler->setTargetType('xxx');
154  $handler->setTriggerRefId(99997);
155  $handler->setTriggerObjId(99996);
156  $handler->setTriggerType('yyy');
157  $handler->setReferenceHandlingType(0);
158  $handler->enableAutomaticValidation(false);
159  $suc = $handler->storeCondition();
160  $this->assertEquals($suc,true);
161 
162  $suc = $handler->checkExists();
163  $this->assertEquals($suc,false);
164 
165  $suc = $handler->delete(99999);
166  $this->assertEquals($suc,true);
167 
168  // syntax check
169  $handler->deleteByObjId(-1);
170  $handler->deleteCondition(-1);
174  }
175 
179  public function testCache()
180  {
181  include_once './Services/AccessControl/classes/class.ilAccessHandler.php';
182 
183  $handler = new ilAccessHandler();
184  $handler->setResults(array(1,2,3));
185  $handler->storeCache();
186  $handler->readCache();
187  $res = $handler->getResults();
188 
189  $this->assertEquals(array(1,2,3),$res);
190  }
191 
192 
193 }
194 ?>