Example #1
0
 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);
 }
Example #2
0
 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'));
 }
Example #4
0
 /** @test */
 public function should_create_from_native()
 {
     $role_title = RoleSlug::fromNative('fake-role-slug');
     $this->assertInstanceOf('Cffs\\Domain\\Model\\Identity\\RoleSlug', $role_title);
 }
Example #5
0
 /**
  * Get the Role's slug
  *
  * @return RoleSlug
  */
 public function slug()
 {
     return RoleSlug::fromNative($this->slug);
 }