Commit 84a9edea authored by Okhin's avatar Okhin

Getting the user test to work, by retrieving the lastInsertId and not assuming it's 3

parent 2559bc0a
...@@ -7,6 +7,8 @@ class UserCreateCommand ...@@ -7,6 +7,8 @@ class UserCreateCommand
private $email; private $email;
private $hash; private $hash;
private $pseudo; private $pseudo;
private $cumul;
private $total;
public function __construct($email, $hash, $pseudo, $cumul, $total) public function __construct($email, $hash, $pseudo, $cumul, $total)
{ {
......
...@@ -39,13 +39,13 @@ class UserHandler ...@@ -39,13 +39,13 @@ class UserHandler
*/ */
public function handleUserCreateCommand(UserCreateCommand $command) public function handleUserCreateCommand(UserCreateCommand $command)
{ {
$stmt = $this->connection->prepare('INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'); $this->connection->executeUpdate('INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)', [
$stmt->bindValue('email', $command->getEmail()); 'email'=> $command->getEmail(),
$stmt->bindValue('hash', $command->getHash()); 'hash'=> $command->getHash(),
$stmt->bindValue('pseudo', $command->getPseudo()); 'pseudo'=> $command->getPseudo(),
$stmt->bindValue('total', $command->getTotal()); 'total'=> $command->getTotal(),
$stmt->bindValue('cumul', $command->getCumul()); 'cumul'=> $command->getCumul(),
$stmt->execute(); ]);
} }
/** /**
......
...@@ -28,6 +28,10 @@ class UserHandlerTest extends FunctionalTest ...@@ -28,6 +28,10 @@ class UserHandlerTest extends FunctionalTest
public function testUserCreateCommand() public function testUserCreateCommand()
{ {
$this->container['command_handler']->handle(new UserCreateCommand('eve@example.org', 'not a hash', 'Eve', 0, 0)); $this->container['command_handler']->handle(new UserCreateCommand('eve@example.org', 'not a hash', 'Eve', 0, 0));
$last_id = $this->container['db']->lastInsertId();
$user = $this->getUser($last_id);
$this->assertSame('eve@example.org', $user['email']);
} }
public function testUserUpdateTotal() public function testUserUpdateTotal()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment