Esempio n. 1
0
 public function testHasPermission()
 {
     $p1 = Permission::create("test_1", "", 1);
     $p2 = Permission::create("test_2", "", 2);
     $p3 = Permission::create("test_4", "", 4);
     $r1 = Role::create("role_1", "", [$p1, $p2]);
     $r2 = Role::create("role_2", "", [$p1, $p2, $p3]);
     $subject_1 = new Subject(1, new RoleSet([$r1, $r2]));
     $this->assertTrue($subject_1->hasPermission($p1));
     $this->assertTrue($subject_1->hasPermission($p2->name));
     $this->assertFalse($subject_1->hasPermission("BS_PERM"));
 }