function it_removes(SqlManager $pdo, \PDOStatement $statement, User $user, UserId $userId)
 {
     $user->id()->shouldBeCalled()->willReturn($userId);
     $userId->id()->shouldBeCalled()->willReturn('theid');
     $pdo->execute(sprintf('DELETE FROM %s WHERE id = :id', SqlUserRepository::TABLE_NAME), ['id' => 'theid'])->shouldBeCalled()->willReturn($statement);
     $this->remove($user);
 }
 function it_updates(SqlManager $pdo, \PDOStatement $statement, User $user, UserId $userId, UserEmail $email)
 {
     $user->id()->shouldBeCalled()->willReturn($userId);
     $userId->id()->shouldBeCalled()->willReturn('theid');
     $user->email()->shouldBeCalled()->willReturn($email);
     $email->getValue()->shouldBeCalled()->willReturn('*****@*****.**');
     $user->password()->shouldBeCalled()->willReturn('password');
     $pdo->execute(sprintf('SELECT COUNT(*) FROM %s WHERE id = :id', SqlUserRepository::TABLE_NAME), [':id' => 'theid'])->shouldBeCalled()->willReturn($statement);
     $statement->fetchColumn()->shouldBeCalled()->willReturn(1);
     $pdo->execute(sprintf('UPDATE %s SET email = :email, password = :password WHERE id = :id', SqlUserRepository::TABLE_NAME), ['id' => 'theid', 'email' => '*****@*****.**', 'password' => 'password'])->shouldBeCalled()->willReturn($statement);
     $this->save($user);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function remove(User $anUser)
 {
     $this->pdo->execute(sprintf('DELETE FROM %s WHERE id = :id', self::TABLE_NAME), ['id' => $anUser->id()->id()]);
 }
 /**
  * Updates the user given into database.
  *
  * @param \Domain\Model\User\User $anUser The user
  */
 private function update(User $anUser)
 {
     $this->pdo->execute(sprintf('UPDATE %s SET email = :email, password = :password WHERE id = :id', self::TABLE_NAME), ['id' => $anUser->id()->id(), 'email' => $anUser->email()->getValue(), 'password' => $anUser->password()]);
 }