/** @test */ final function it_can_clear_permissions_using_action_aliases() { $this->manager->alias('manage', ['read', 'write']); $lock = $this->getCallerLock(); $lock->allow('manage', 'accounts'); $this->assertTrue($lock->can('manage', 'accounts')); $this->assertTrue($lock->can('read', 'accounts')); $this->assertTrue($lock->can('write', 'accounts')); $lock->clear('manage', 'accounts'); $this->assertTrue($lock->cannot('manage', 'accounts')); $this->assertTrue($lock->cannot('read', 'accounts')); $this->assertTrue($lock->cannot('write', 'accounts')); }
/** @test */ final function it_can_check_actions_from_aliases() { $this->manager->alias('manage', ['create', 'read', 'update', 'delete']); $lock = $this->getCallerLock(); $lock->allow('manage', 'accounts'); $this->assertFalse($lock->can('manage')); $this->assertTrue($lock->can('manage', 'accounts')); $this->assertTrue($lock->can('manage', 'accounts', 1)); $this->assertFalse($lock->can('manage', 'events')); $this->assertTrue($lock->can('read', 'accounts')); $this->assertTrue($lock->can(['read', 'update'], 'accounts')); // If one of the aliased actions is explicitly denied, it cannot pass anymore. $lock->deny('create'); $this->assertTrue($lock->can('manage', 'accounts')); $this->assertFalse($lock->can('create', 'accounts')); $this->assertTrue($lock->can(['read', 'update', 'delete'], 'accounts')); }