function its_user_of_id(SqlManager $pdo, \PDOStatement $statement, UserId $userId) { $userId->id()->shouldBeCalled()->willReturn('theid'); $pdo->execute(sprintf('SELECT * FROM %s WHERE id = :id', SqlUserRepository::TABLE_NAME), ['id' => 'theid'])->shouldBeCalled()->willReturn($statement); $statement->fetch(\PDO::FETCH_ASSOC)->shouldBeCalled()->willReturn(['id' => 'theid', 'email' => '*****@*****.**', 'password' => 'password']); $this->userOfId($userId)->shouldReturnAnInstanceOf('Domain\\Model\\User\\User'); }
/** * {@inheritdoc} */ public function userOfId(UserId $anId) { $statement = $this->pdo->execute(sprintf('SELECT * FROM %s WHERE id = :id', self::TABLE_NAME), ['id' => $anId->id()]); if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { return $this->buildUser($row); } return; }
function it_should_be_equals(UserId $userId) { $userId->id()->shouldBeCalled()->willReturn('theid'); $this->equals($userId)->shouldReturn(true); }
/** * Method that checks if the user id given is equal to the current. * * @param \Domain\Model\User\UserId $anId The user id * * @return bool */ public function equals(UserId $anId) { return $this->id() === $anId->id(); }