Commit d06d9bd4 authored by okhin's avatar okhin 🚴

Merge branch...

Merge branch '38-la-structure-des-piplomes-a-changer-le-finder-n-est-plus-fonctionnels' into 'preprod'

Resolve "La structure des piplomes à changer, le Finder n'est plus fonctionnels."

Closes #38

See merge request !13
parents 33f28af4 cb111eba
Pipeline #2046 passed with stages
in 10 seconds
......@@ -54,6 +54,19 @@ class AddressSeeder extends AbstractSeed
'user_id' => 1,
'defaut' => false,
),
array(
'id' => 5,
'nom' => 'Bob address',
'adresse' => '4 rue Ménars',
'adresse2' => null,
'codepostal' => 75003,
'ville' => 'Paris',
'etat' => null,
'pays' => 'France',
'alias' => 'Third address',
'user_id' => 2,
'defaut' => false,
),
);
$this->table('adresses')->insert($data)->save();
......
......@@ -29,7 +29,7 @@ class CounterpartSeeder extends AbstractSeed
'datec' => '2016-06-22 12:34',
'user_id' => 2,
'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie]
'taille' => 8,
'taille' => 2,
'status' => 1,
'adresse_id' => null,
),
......
......@@ -23,7 +23,7 @@ class DonationSeeder extends AbstractSeed
'lang' => 'fr_FR',
'cadeau' => 1,
'abo' => 1,
'taille' => 8,
'taille' => 2,
'public' => 0,
'pdf' => 'pdf',
'decimale' => 2,
......@@ -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' => 3,
'user_id' => 2,
'identifier' => 'id2',
),
array(
'id' => 3,
'status' => 100,
'datec' => '2016-06-10 12:34',
'somme' => 100,
'lang' => 'fr_FR',
'cadeau' => 1,
'abo' => 1,
'taille' => 8,
'public' => 1,
'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',
)
);
......
......@@ -34,19 +34,20 @@ class CounterpartFinder
// @TODO: This part is probably not working.
if ('piplome' === $counterpart['quoi']) {
$query = <<<EOQ
SELECT d.id AS id, a.nom as pseudo, d.pdf as pdf
SELECT d.id as id, a.nom as pseudo, d.pdf as pdf
FROM dons d
JOIN adresses a ON a.id = d.adresse_id
WHERE d.id = :size
JOIN contreparties c ON c.id = d.taille
WHERE d.taille = :size
EOQ;
$pdf = $this->connection->fetchAssoc($query, [
'size' => $counterpart['taille']
]);
if (false !== $pdf) {
$contrepartie['pdf_id'] = $pdf['id'];
$contrepartie['pdf_nom'] = $pdf['pseudo'];
$contrepartie['pdf_url'] = $pdf['pdf'];
$counterpart['pdf_id'] = $pdf['id'];
$counterpart['pdf_nom'] = $pdf['pseudo'];
$counterpart['pdf_url'] = $pdf['pdf'];
}
}
......
......@@ -19,12 +19,12 @@ class CounterpartFinderTest extends FunctionalTest
'user_id' => '2',
'datec' => '2016-06-22 12:34:00',
'quoi' => 'piplome',
'taille' => '8',
'taille' => '2',
'status' => '1',
'adresse_id' => null,
'pdf_id' => '',
'pdf_nom' => '',
'pdf_url' => '',
'pdf_id' => '1',
'pdf_nom' => 'Main',
'pdf_url' => 'pdf',
];
$this->assertEquals($expectedCounterpart, $firstCounterpart);
}
......
......@@ -21,7 +21,7 @@ class DonationFinderTest extends FunctionalTest
'lang' => 'fr_FR',
'cadeau' => '1',
'abo' => '1',
'taille' => '8',
'taille' => '2',
'public' => '0',
'pdf' => 'pdf',
'decimale' => '2',
......@@ -40,4 +40,13 @@ class DonationFinderTest extends FunctionalTest
];
$this->assertEquals($expectedDonation, $donations[1]);
}
public function testAdminSearchDonations()
{
$this->assertCount(1, $this->container['donation_finder']->adminSearch($text='alice@example.org', $sum='', $public='', $status=''));
$this->assertCount(2, $this->container['donation_finder']->adminSearch($text='', $sum='1000', $public='', $status=''));
$this->assertCount(2, $this->container['donation_finder']->adminSearch($text='', $sum='', $public='0', $status=''));
$this->assertCount(2, $this->container['donation_finder']->adminSearch($text='', $sum='', $public='', $status='1'));
}
}
......@@ -23,4 +23,11 @@ class UserFinderTest extends FunctionalTest
];
$this->assertEquals($expectedUser, $user);
}
public function testAdminSearch()
{
$this->assertCount(1, $this->container['user_finder']->adminSearch($text='alice@example.org', $status=''));
$this->assertCount(2, $this->container['user_finder']->adminSearch($text='', $status='1'));
}
}
......@@ -10,7 +10,7 @@ use LQDN\Tests\Functional\FunctionalTest;
class AddressHandlerTest extends FunctionalTest
{
public function notestAddressUsedDelete()
public function testAddressUsedDelete()
{
$this->assertTrue($this->addressExists(1));
......@@ -27,7 +27,7 @@ class AddressHandlerTest extends FunctionalTest
$this->assertFalse($this->addressExists(2));
}
public function notestAddressUpdate()
public function testAddressUpdate()
{
$this->assertTrue($this->addressExists(1));
$this->assertTrue($this->isDefaultAddress(1));
......@@ -40,7 +40,7 @@ class AddressHandlerTest extends FunctionalTest
$this->assertTrue($this->isDefaultAddress(2));
}
public function notestAddressCreateWithSpecialChars()
public function testAddressCreateWithSpecialChars()
{
$this->assertTrue($this->addressExists(1));
$this->assertTrue($this->isDefaultAddress(1));
......
<?php
namespace LQDN\Tests\Functionnal\Handler;
use LQDN\CommandHandler;
use LQDN\Tests\Functional\FunctionalTest;
class CommandHandlerTest extends Functionaltest
{
public function testCommandNotAnObjectException()
{
$this->setExpectedException('LQDN\Exception\CommandNotAnObjectException');
$this->container['command_handler']->handle("Not a command object");
}
public function testCommandNotHandledException()
{
$this->setExpectedException('LQDN\Exception\CommandNotHandledException');
$this->container['command_handler']->handle((object)[]);
}
}
?>
......@@ -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