예제 #1
0
 public function generateUsername(FirstName $firstName, LastName $lastName, $offset = 1)
 {
     $fullNameStr = $firstName->toString() . $lastName->toString();
     $modifier = $offset > 1 ? $offset : '';
     $username = Username::fromNative(str_slug($fullNameStr . $modifier));
     if ($this->userRepository->userOfUsername($username)) {
         return $this->generateUsername($firstName, $lastName, $offset + 1);
     }
     return $username;
 }
예제 #2
0
 /** @test */
 public function should_generate_valid_username_if_already_exists()
 {
     $first = FirstName::fromNative('Evey');
     $last = LastName::fromNative('Edward');
     $this->repository->shouldReceive('userOfUsername')->andReturn(true, true, null);
     $username = $this->registrar->generateUsername($first, $last);
     $this->assertEquals('eveyedward3', $username->toString());
 }
예제 #3
0
파일: UserStub.php 프로젝트: Evyy/cffs-api
 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);
 }
예제 #4
0
 /** @test */
 public function should_create_from_native()
 {
     $last_name = LastName::fromNative('Edward');
     $this->assertInstanceOf('Cffs\\Domain\\Model\\Identity\\LastName', $last_name);
 }
예제 #5
0
파일: User.php 프로젝트: Evyy/cffs-api
 /**
  * Set the User's last name
  *
  * @param LastName $lastName
  * @return void
  */
 private function setLastName(LastName $lastName)
 {
     $this->lastName = $lastName->toString();
 }