/** @test */ public function should_find_user_by_id() { $this->executor->execute($this->loader->getFixtures()); $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $user = $this->repository->userOfId($id); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user); $this->assertEquals($id, $user->id()); }
/** * Find a User by their id * * @param string $id * @return User */ private function findUserById($id) { $user = $this->users->userById(UserId::fromString($id)); if ($user) { return $user; } throw new ValueNotFoundException("{$id} is not a valid user id"); }
/** * Load the User fixtures * * @param ObjectManager $manager * @return void */ public function load(ObjectManager $manager) { $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $email = new Email('*****@*****.**'); $username = new Username('username'); $password = new HashedPassword('qwerty'); $user = User::register($id, $email, $username, $password); $manager->persist($user); $manager->flush(); }
/** @test */ public function should_return_user_id_as_string() { $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $id->toString()); $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', (string) $id); }
/** * Get the User's id * * @return UserId; */ public function id() { return UserId::fromString($this->id); }