diff --git a/db/seeds/CounterpartSeeder.php b/db/seeds/CounterpartSeeder.php index b47cdf580ef8e3f9cc9891b9bf0aeb78ee878025..9dced14093cd7d878a8de7446290130d2e0ac932 100644 --- a/db/seeds/CounterpartSeeder.php +++ b/db/seeds/CounterpartSeeder.php @@ -30,7 +30,7 @@ class CounterpartSeeder extends AbstractSeed 'user_id' => 2, 'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie] 'taille' => 2, - 'status' => 1, + 'status' => 2, 'adresse_id' => null, ), ); diff --git a/src/LQDN/Handler/AddressHandler.php b/src/LQDN/Handler/AddressHandler.php index c4dda1d2f2c3787e94fc075b51507a4d8f7b65fc..efb393db8775c64faed0bcd9792a0b88d1267520 100644 --- a/src/LQDN/Handler/AddressHandler.php +++ b/src/LQDN/Handler/AddressHandler.php @@ -92,7 +92,7 @@ EOF; private function addressUsed($addressId) { $count = (int) $this->connection->fetchColumn( - "SELECT count(1) FROM contreparties, dons WHERE contreparties.adresse_id = :id OR dons.adresse_id = :id", + "SELECT count(1) FROM contreparties, dons WHERE contreparties.adresse_id = :id AND contreparties.status = 1;", [ 'id' => $addressId, ], diff --git a/tests/functional/Finder/CounterpartFinderTest.php b/tests/functional/Finder/CounterpartFinderTest.php index ac46f81b2f18f431c00dd1fd71265594a5e4733f..8f2a15cb6303ef300fe417530857973457258fdf 100644 --- a/tests/functional/Finder/CounterpartFinderTest.php +++ b/tests/functional/Finder/CounterpartFinderTest.php @@ -20,7 +20,7 @@ class CounterpartFinderTest extends FunctionalTest 'datec' => '2016-06-22 12:34:00', 'quoi' => 'piplome', 'taille' => '2', - 'status' => '1', + 'status' => '2', 'adresse_id' => null, 'pdf_id' => '1', 'pdf_nom' => 'Main', diff --git a/tests/functional/Handler/AddressHandlerTest.php b/tests/functional/Handler/AddressHandlerTest.php index 84393be61599089009cc3ea26498e552f042a777..81558168925e6fdf564d75d46eff1847d3c4bf72 100644 --- a/tests/functional/Handler/AddressHandlerTest.php +++ b/tests/functional/Handler/AddressHandlerTest.php @@ -16,6 +16,10 @@ class AddressHandlerTest extends FunctionalTest $this->setExpectedException('LQDN\Exception\AddressUsedException'); $this->container['command_handler']->handle(new AddressDeleteCommand(1, 1)); + + $this->container['command_handler']->handle(new AddressDeleteCommand(2, 1)); + + $this->assertFalse($this->addressExists(2)); } public function testAdressDelete()