Commit cb111eba authored by okhin's avatar okhin 🚴

Finally, extract the PDF attributes from tables.

parent 3520bb48
Pipeline #2042 passed with stages
in 12 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' => 1,
'taille' => 2,
'status' => 1,
'adresse_id' => null,
),
......
......@@ -63,7 +63,7 @@ class DonationSeeder extends AbstractSeed
'fdnn_user' => 1234567890,
'color_2' => 'red',
'cumul' => 1000,
'adresse_id' => 1,
'adresse_id' => 3,
'user_id' => 2,
'identifier' => 'id2',
),
......
......@@ -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 = :don_id
JOIN contreparties c ON c.id = d.taille
WHERE d.taille = :size
EOQ;
$pdf = $this->connection->fetchAssoc($query, [
'don_id' => $counterpart['']
'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,18 +19,13 @@ class CounterpartFinderTest extends FunctionalTest
'user_id' => '2',
'datec' => '2016-06-22 12:34:00',
'quoi' => 'piplome',
'taille' => '1',
'taille' => '2',
'status' => '1',
'adresse_id' => null,
'pdf_id' => '1',
'pdf_nom' => 'bob@example.org',
'pdf_nom' => 'Main',
'pdf_url' => 'pdf',
];
$this->assertEquals($expectedCounterpart, $firstCounterpart);
// Test the PDF attributes
$this->assertEquals(2, $firstCounterpart['pdf_id']);
$this->assertEquals('Bob', $firstCounterpart['pdf_nom']);
$this->assertEquals('http://example.org/pdf/2', $firstCounterpart['pdf_url']);
}
}
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