Exemple #1
0
 /** @test */
 public function should_test_equality()
 {
     $one = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $two = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $three = UserId::generate();
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
Exemple #2
0
 public function setUp()
 {
     $this->id = UserId::generate();
     $this->email = new Email('*****@*****.**');
     $this->username = new Username('my_username');
     $this->firstName = new Firstname('first');
     $this->lastName = new Lastname('last');
     $this->password = new HashedPassword('super_secret_password');
 }
 /** @test */
 public function should_register_new_user()
 {
     $this->repository->shouldReceive('userOfEmail')->andReturn(null);
     $this->repository->shouldReceive('userOfUsername')->andReturn(null);
     $this->repository->shouldReceive('nextIdentity')->andReturn(UserId::generate());
     $this->hashing->shouldReceive('hash')->andReturn(new HashedPassword('password'));
     $this->repository->shouldReceive('add');
     $user = $this->registrar->register('*****@*****.**', 'First', 'Last', 'username', 'password');
     $this->assertInstanceOf(User::class, $user);
 }
 /** @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'));
 }
Exemple #5
0
 public static function create()
 {
     //        return 'here';
     $faker = Factory::create();
     $identifier = UserId::generate();
     $email = Email::fromNative($faker->email);
     $first = FirstName::fromNative($faker->word);
     $last = LastName::fromNative($faker->word);
     $username = Username::fromNative($faker->word);
     $password = HashedPassword::fromNative(str_random(10));
     return User::create($identifier, $email, $first, $last, $username, $password);
 }
 /**
  * Return the next identity
  *
  * @return UserId
  */
 public function nextIdentity()
 {
     return UserId::generate();
 }