public static function create() { $faker = Factory::create(); $identifier = RoleId::generate(); $title = RoleTitle::fromNative($faker->word); $slug = RoleSlug::fromNative(Str::slug($title)); return Role::define($identifier, $title, $slug); }
public function setUp() { parent::setUp(); $this->id = RoleId::generate(); $this->title = RoleTitle::fromNative('Asdf Qwerty'); $this->slug = RoleSlug::fromNative(Str::slug($this->title->toString())); $this->role = Role::define($this->id, $this->title, $this->slug); }
/** @test */ public function should_throw_exception_user_does_not_have_permissions() { $role = $this->role; $user = $this->user; $user->shouldReceive('hasRole')->andReturn(false); $user->shouldReceive('id')->andReturn(UserId::generate()); $role->shouldReceive('slug')->andReturn(RoleSlug::fromNative('asdf')); $this->setExpectedException(UserDoesNotHaveRolePermissions::class); $this->guard->handle(compact('user', 'role')); }
/** @test */ public function should_create_from_native() { $role_title = RoleSlug::fromNative('fake-role-slug'); $this->assertInstanceOf('Cffs\\Domain\\Model\\Identity\\RoleSlug', $role_title); }
/** * Set the Role's slug * * @param RoleSlug $slug * @return void */ private function setSlug(RoleSlug $slug) { $this->slug = $slug->toString(); }