Commit fd678f60 authored by okhin's avatar okhin 🚴

N'interdire la suppression que si une contrepartie en statut 1 est associée à l'adresse

parent 7cfc2e76
Pipeline #2223 passed with stages
in 11 seconds
...@@ -30,7 +30,7 @@ class CounterpartSeeder extends AbstractSeed ...@@ -30,7 +30,7 @@ class CounterpartSeeder extends AbstractSeed
'user_id' => 2, 'user_id' => 2,
'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie] 'quoi' => 'piplome', // [piplome|pibag|pishirt|hoodie]
'taille' => 2, 'taille' => 2,
'status' => 1, 'status' => 2,
'adresse_id' => null, 'adresse_id' => null,
), ),
); );
......
...@@ -92,7 +92,7 @@ EOF; ...@@ -92,7 +92,7 @@ EOF;
private function addressUsed($addressId) private function addressUsed($addressId)
{ {
$count = (int) $this->connection->fetchColumn( $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, 'id' => $addressId,
], ],
......
...@@ -20,7 +20,7 @@ class CounterpartFinderTest extends FunctionalTest ...@@ -20,7 +20,7 @@ class CounterpartFinderTest extends FunctionalTest
'datec' => '2016-06-22 12:34:00', 'datec' => '2016-06-22 12:34:00',
'quoi' => 'piplome', 'quoi' => 'piplome',
'taille' => '2', 'taille' => '2',
'status' => '1', 'status' => '2',
'adresse_id' => null, 'adresse_id' => null,
'pdf_id' => '1', 'pdf_id' => '1',
'pdf_nom' => 'Main', 'pdf_nom' => 'Main',
......
...@@ -16,6 +16,10 @@ class AddressHandlerTest extends FunctionalTest ...@@ -16,6 +16,10 @@ class AddressHandlerTest extends FunctionalTest
$this->setExpectedException('LQDN\Exception\AddressUsedException'); $this->setExpectedException('LQDN\Exception\AddressUsedException');
$this->container['command_handler']->handle(new AddressDeleteCommand(1, 1)); $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() public function testAdressDelete()
......
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