/**
  * @expectedException \RBAC\Exception\InsufficientPermission
  */
 public function testRequirePermission()
 {
     $p1 = Permission::create("test_1", "", 1);
     $p2 = Permission::create("test_2", "", 2);
     $r1 = Role::create("role_1", "", [$p1, $p2]);
     $subject = new Subject(1, new RoleSet([$r1]));
     $subject->requirePermission($p1);
     $subject->requirePermission($p2->name);
     $subject->requirePermission("bs_perm");
 }
Beispiel #2
0
 /**
  * Sets the user context for this class. It basically allows two methods of using this class, either by constructing it or manually setting it.
  * 
  * @param $subject_id  int
  * @param $role_set object
  * 
  * @return null
  */
 public function set_user($subject_id, RoleSet $role_set = null)
 {
     parent::__construct($subject_id, $role_set);
     $this->user_data['id'] = $subject_id;
 }
 public function testRoleAddSubject()
 {
     $role = $this->rm->roleFetchById(1);
     $this->assertTrue($this->rm->roleSave($role));
     $subject = new Subject(99);
     $initial_role_count = sizeof($subject->getRoleSet()->getRoles());
     $this->assertTrue($this->rm->roleAddSubject($role, $subject));
     $this->assertEquals($initial_role_count + 1, sizeof($subject->getRoleSet()->getRoles()));
 }