From c96d429df8ab57339a4008a46c60b12961966975 Mon Sep 17 00:00:00 2001 From: Bastien Le Querrec <blq@laquadrature.net> Date: Thu, 7 Oct 2021 18:51:29 +0200 Subject: [PATCH] fix test --- .../functional/Handler/AddressHandlerTest.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/functional/Handler/AddressHandlerTest.php b/tests/functional/Handler/AddressHandlerTest.php index a5798a5..27fcc15 100644 --- a/tests/functional/Handler/AddressHandlerTest.php +++ b/tests/functional/Handler/AddressHandlerTest.php @@ -67,10 +67,10 @@ class AddressHandlerTest extends FunctionalTest $latestAddress = $this->getLatestAddress(); - $this->container['command_handler']->handle(new AddressUpdateCommand($latestAddress['id'], 1, 'LQDN', '115 rue de Ménilmontant', '', 75020, 'Paris', 'France', 'IDF')); + $this->container['command_handler']->handle(new AddressUpdateCommand(1, 1, 'LQDN', '115 rue de Ménilmontant', '', 75020, 'Paris', 'France', 'IDF')); $expectedAddress = [ - 'id' => $latestAddress['id'], + 'id' => '1', 'user_id' => '1', 'nom' => 'LQDN', 'adresse' => '115 rue de Ménilmontant', @@ -81,7 +81,7 @@ class AddressHandlerTest extends FunctionalTest 'etat' => 'IDF', ]; - $updatedAddress = $this->getLatestAddress(); + $updatedAddress = $this->getAddressById(1); $this->assertSame($expectedAddress, $updatedAddress); } @@ -106,4 +106,16 @@ class AddressHandlerTest extends FunctionalTest { return $this->container['db']->fetchAssoc("SELECT * FROM adresses ORDER BY id DESC LIMIT 1"); } + + /** + * Retrieve address by its ID. + * + * @param int $id + * + * @return [] + */ + private function getAddressById($id) + { + return $this->container['db']->fetchAssoc("SELECT id,user_id,nom,adresse,adresse2,codepostal,ville,pays,etat FROM adresses WHERE id = $id LIMIT 1"); + } } -- GitLab