/** * @param \Artesaos\Defender\Permission $permission * @param string $roleName */ protected function attachPermissionToRole($permission, $roleName) { // Check if role exists if ($role = $this->roleRepository->findByName($roleName)) { $role->attachPermission($permission); $this->info('Permission attached successfully to role'); } else { $this->error('Not possible to attach permission. Role not found'); } }
/** * Get the role with the given name. * * @param string $roleName * * @return \Artesaos\Defender\Role|null */ public function findRole($roleName) { return $this->roleRepository->findByName($roleName); }
public function it_should_return_true_when_the_given_role_exists(RoleRepository $roleRepository, $role) { $role->beADoubleOf('Artesaos\\Defender\\Role'); $roleRepository->findByName('foo')->shouldBeCalled()->willReturn($role); $this->roleExists('foo')->shouldReturn(true); }