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
private $email;
private $hash;
private $pseudo;
private $cumul;
private $total;
public function __construct($email, $hash, $pseudo, $cumul, $total)
{
......
......@@ -39,13 +39,13 @@ class UserHandler
*/
public function handleUserCreateCommand(UserCreateCommand $command)
{
$stmt = $this->connection->prepare('INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)');
$stmt->bindValue('email', $command->getEmail());
$stmt->bindValue('hash', $command->getHash());
$stmt->bindValue('pseudo', $command->getPseudo());
$stmt->bindValue('total', $command->getTotal());
$stmt->bindValue('cumul', $command->getCumul());
$stmt->execute();
$this->connection->executeUpdate('INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)', [
'email'=> $command->getEmail(),
'hash'=> $command->getHash(),
'pseudo'=> $command->getPseudo(),
'total'=> $command->getTotal(),
'cumul'=> $command->getCumul(),
]);
}
/**
......
......@@ -28,6 +28,10 @@ class UserHandlerTest extends FunctionalTest
public function testUserCreateCommand()
{
$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()
......
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