コード例 #1
0
 /**
  * Check that an Email is unique
  *
  * @param Email $email
  * @throws ValueIsNotUniqueException
  * @return void
  */
 private function checkEmailIsUnique(Email $email)
 {
     $specification = new EmailIsUnique($this->userRepository);
     if (!$specification->isSatisfiedBy($email)) {
         throw new ValueIsNotUniqueException("{$email} is already registered");
     }
 }
コード例 #2
0
 /** @test */
 public function should_return_false_when_not_unique()
 {
     $this->repository->shouldReceive('userOfEmail')->andReturn(['id' => 1]);
     $this->assertFalse($this->spec->isSatisfiedBy(new Email('*****@*****.**')));
 }