From 3036c91e783ff9daff2ac5d93a470e9da5f27c33 Mon Sep 17 00:00:00 2001 From: cvilleger Date: Mon, 30 Sep 2024 11:08:01 +0200 Subject: [PATCH 1/2] (fix): Set to zero when population is null --- src/Client.php | 2 +- tests/GeoGouvTest.php | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Client.php b/src/Client.php index cfe596f..ffd2eea 100644 --- a/src/Client.php +++ b/src/Client.php @@ -52,7 +52,7 @@ public function getCommunesByDepartementCode(string $departementCode): array coordinates: $commune['centre']['coordinates'], ), surface: $commune['surface'], - population: $commune['population'], + population: $commune['population'] ?? 0, departement: new CommuneDepartement( nom: $commune['departement']['nom'], code: $commune['departement']['code'], diff --git a/tests/GeoGouvTest.php b/tests/GeoGouvTest.php index 614c3dc..8f2c413 100644 --- a/tests/GeoGouvTest.php +++ b/tests/GeoGouvTest.php @@ -9,11 +9,6 @@ use Cvilleger\GeoGouv\Model\Departement; use PHPUnit\Framework\TestCase; -/** - * @internal - * - * @coversNothing - */ class GeoGouvTest extends TestCase { public function testGetDepartments(): void @@ -30,9 +25,11 @@ public function testGetCommunesByDepartementCode(): void { $client = new Client(); - $communes = $client->getCommunesByDepartementCode('01'); + foreach ($client->getDepartements() as $departement) { + $communes = $client->getCommunesByDepartementCode($departement->code); - self::assertIsArray($communes); - self::assertInstanceOf(Commune::class, $communes[0]); + self::assertIsArray($communes); + self::assertInstanceOf(Commune::class, $communes[0]); + } } } From 49576b24e89c32bc10e4e885797064857c3dad70 Mon Sep 17 00:00:00 2001 From: cvilleger Date: Mon, 30 Sep 2024 11:09:40 +0200 Subject: [PATCH 2/2] (fix): Set to zero when population is null --- tests/GeoGouvTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/GeoGouvTest.php b/tests/GeoGouvTest.php index 8f2c413..f7bebcc 100644 --- a/tests/GeoGouvTest.php +++ b/tests/GeoGouvTest.php @@ -9,6 +9,11 @@ use Cvilleger\GeoGouv\Model\Departement; use PHPUnit\Framework\TestCase; +/** + * @internal + * + * @coversNothing + */ class GeoGouvTest extends TestCase { public function testGetDepartments(): void