コード例 #1
0
 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');
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 function it_should_be_equals(UserId $userId)
 {
     $userId->id()->shouldBeCalled()->willReturn('theid');
     $this->equals($userId)->shouldReturn(true);
 }
コード例 #4
0
ファイル: UserId.php プロジェクト: benatespina/ddd-symfony
 /**
  * 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();
 }