Commit 39a56d17 authored by okhin's avatar okhin 🚴

Improving tests to recover donations by user

parent cbbbadbb
Pipeline #2026 canceled with stages
......@@ -39,7 +39,59 @@ class DonationSeeder extends AbstractSeed
'cumul' => 1000,
'adresse_id' => 1,
'user_id' => 1,
'identifier' => 'id1',
'identifier' => 'id1',
),
array(
'id' => 2,
'status' => 1,
'datec' => '2016-06-10 12:34',
'somme' => 1000,
'lang' => 'fr_FR',
'cadeau' => 1,
'abo' => 1,
'taille' => 8,
'public' => 0,
'pdf' => 'pdf',
'decimale' => 2,
'datee' => '2016-06-10 12:34',
'mailsent' => 1,
'color' => 'blue',
'pi_x' => 3,
'pi_y' => 3,
'hash' => 'hash',
'taille_h' => 8,
'fdnn_user' => 1234567890,
'color_2' => 'red',
'cumul' => 1000,
'adresse_id' => 1,
'user_id' => 2,
'identifier' => 'id2',
),
array(
'id' => 3,
'status' => 1,
'datec' => '2016-06-10 12:34',
'somme' => 1000,
'lang' => 'fr_FR',
'cadeau' => 1,
'abo' => 1,
'taille' => 8,
'public' => 0,
'pdf' => 'pdf',
'decimale' => 2,
'datee' => '2016-06-10 12:34',
'mailsent' => 1,
'color' => 'blue',
'pi_x' => 3,
'pi_y' => 3,
'hash' => 'hash',
'taille_h' => 8,
'fdnn_user' => 1234567890,
'color_2' => 'red',
'cumul' => 1000,
'adresse_id' => 1,
'user_id' => 2,
'identifier' => 'id3',
)
);
......
......@@ -19,11 +19,7 @@ class CommandHandler
*/
public function handle($command)
{
try {
$method = $this->getHandleMethod($command);
} catch (Exception $e) {
throw new CommandNotHandledException();
}
$method = $this->getHandleMethod($command);
foreach ($this->handlers as $handler) {
if (method_exists($handler, $method)) {
......
......@@ -25,6 +25,13 @@ class DonationHandlerTest extends FunctionalTest
$this->assertEquals('', $this->getDonation(1)['pdf']);
}
private function testDonationByUser()
{
$this->assertEquals(2, count($this->getDonationByUser(2)));
$this->assertEquals(2, $this->getDonationByUser(2)[0]['user_id']);
}
/**
* Retrieve a donation
*
......@@ -34,4 +41,14 @@ class DonationHandlerTest extends FunctionalTest
{
return $this->container['db']->fetchAssoc("SELECT * FROM dons WHERE id = $id");
}
/**
* Retrieve donations by userid
*
* @return []
*/
private function getDonationByUser($uid)
{
return $this->container['db']->fetchAll("SELECT * FROM dons WHERE user_id = $uid");
}
}
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