Skip to content
Extraits de code Groupes Projets
Valider 1f5a8dcd rédigé par Okhin's avatar Okhin
Parcourir les fichiers

Adding a user create command

parent 54e2dad3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!55Guinness/don fix admin user view,!54Modification front
<?php
namespace LQDN\Command;
class UserCreateCommand
{
private $email;
private $hash;
private $pseudo;
public function __construct($email, $hash, $pseudo, $cumul, $total)
{
$this->hash = $hash;
$this->email = $email;
$this->pseudo = $pseudo;
$this->total = $total;
$this->cumul = $cumul;
}
public function getHash()
{
return $this->hash;
}
public function getEmail()
{
return $this->email;
}
public function getPseudo()
{
return $this->pseudo;
}
public function getTotal()
{
return $this->total;
}
public function getCumul()
{
return $this->cumul;
}
}
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; ...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use LQDN\Command\UserUpdateByAdminCommand; use LQDN\Command\UserUpdateByAdminCommand;
use LQDN\Command\UserUpdateTotalCommand; use LQDN\Command\UserUpdateTotalCommand;
use LQDN\Command\UserUpdateCumulCommand; use LQDN\Command\UserUpdateCumulCommand;
use LQDN\Command\UserCreateCommand;
class UserHandler class UserHandler
{ {
...@@ -31,6 +32,22 @@ class UserHandler ...@@ -31,6 +32,22 @@ class UserHandler
]); ]);
} }
/**
* Create a user in database
*
* @param 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)');
$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();
}
/** /**
* Update the user total * Update the user total
* *
......
...@@ -5,6 +5,7 @@ namespace LQDN\Tests\Functional\Handler; ...@@ -5,6 +5,7 @@ namespace LQDN\Tests\Functional\Handler;
use LQDN\Command\UserUpdateByAdminCommand; use LQDN\Command\UserUpdateByAdminCommand;
use LQDN\Command\UserUpdateTotalCommand; use LQDN\Command\UserUpdateTotalCommand;
use LQDN\Command\UserUpdateCumulCommand; use LQDN\Command\UserUpdateCumulCommand;
use LQDN\Command\UserCreateCommand;
use LQDN\Tests\Functional\FunctionalTest; use LQDN\Tests\Functional\FunctionalTest;
class UserHandlerTest extends FunctionalTest class UserHandlerTest extends FunctionalTest
...@@ -24,6 +25,11 @@ class UserHandlerTest extends FunctionalTest ...@@ -24,6 +25,11 @@ class UserHandlerTest extends FunctionalTest
$this->assertSame('This is foobar avé dé accênts !', $user['commentaire']); $this->assertSame('This is foobar avé dé accênts !', $user['commentaire']);
} }
public function testUserCreateCommand()
{
$this->container['command_handler']->handle(new UserCreateCommand('eve@example.org', 'not a hash', 'Eve', 0, 0));
}
public function testUserUpdateTotal() public function testUserUpdateTotal()
{ {
$this->container['command_handler']->handle(new UserUpdateTotalCommand(1, 600)); $this->container['command_handler']->handle(new UserUpdateTotalCommand(1, 600));
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter