diff --git a/tests/functional/Handler/AddressHandlerTest.php b/tests/functional/Handler/AddressHandlerTest.php index a5798a53cbdc9523a9c74188a137c7898851d32c..27fcc15e5d7a18c635f6db13830d56e127acff4b 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"); + } }