public function it_can_create_a_user() { $email = '*****@*****.**'; $password = '******'; $displayName = 'R2D2'; $this->userRepository->create(new Argument\Token\TypeToken(User::class))->shouldBeCalled(); $user = $this->createUser(EmailAddress::get($email), $password, $displayName); $user->getUuid()->shouldHaveType(UuidInterface::class); $user->getEmailAddress()->toString()->shouldReturn($email); $user->getDisplayName()->shouldReturn($displayName); $passwordHash = $user->getPassword()->getWrappedObject(); if (!password_verify($password, $passwordHash)) { throw new \RuntimeException('Password did not verify.'); } }
public function createUser(EmailAddress $emailAddress, string $password, string $displayName) : User { $user = new User(Uuid::uuid4(), $emailAddress, password_hash($password, $this->algorithm, $this->passwordOptions), $displayName); $this->userRepository->create($user); return $user; }