diff --git a/docker/Dockerfile b/docker/Dockerfile index 31f9c96..bbc9cf2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,8 @@ FROM public.ecr.aws/unocha/php-k8s:8.2-stable as builder ARG BRANCH_ENVIRONMENT ENV APP_ENV=PROD \ PUBLIC_DIR=/srv/www/public \ - COMPOSER_MEMORY_LIMIT=-1 + COMPOSER_MEMORY_LIMIT=-1 \ + COMPOSER_ALLOW_SUPERUSER=1 COPY . /srv/www WORKDIR /srv/www RUN composer install --no-scripts --prefer-dist --optimize-autoloader && \ diff --git a/src/Entity/KeyFigures.php b/src/Entity/KeyFigures.php index 04ae14f..bd3ab56 100644 --- a/src/Entity/KeyFigures.php +++ b/src/Entity/KeyFigures.php @@ -545,7 +545,7 @@ public function fromValues(array $values): self { $this->country = $values['country']; $this->year = $values['year']; $this->name = $values['name']; - $this->value = $values['value']; + $this->value = $values['value'] ?? '0.00'; $this->valueString = $values['value_string'] ?? NULL; $this->valueType = $values['value_type'] ?? 'numeric'; $this->url = $values['url'] ?? ''; diff --git a/tests/KeyFiguresSrc3BatchTest.php b/tests/KeyFiguresSrc3BatchTest.php index 6c036e1..5195f3d 100644 --- a/tests/KeyFiguresSrc3BatchTest.php +++ b/tests/KeyFiguresSrc3BatchTest.php @@ -106,4 +106,46 @@ public function testOnSource3AsUser3(): void $this->assertArrayHasKey(strtolower('src3_afg_2022_Indicator'), $body['successful']); } + public function testOnSource3WithoutValueAsUser3(): void + { + $record = [ + 'plan_id' => 1159, + 'external_id' => 1159, + 'updated' => '2023-11-28 14:52:57', + 'name' => 'Top sectors', + 'year' => '2024', + 'code' => 'HCMR24', + 'iso3' => 'cmr', + 'country' => 'Cameroon', + 'source' => 'FTS', + 'url' => 'https://fts.unocha.org/appeals/1159/summary', + 'description' => 'Cameroon Humanitarian Response Plan 2024 [1159]', + 'total_funding' => 0, + 'value_type' => 'list', + 'archived' => 0, + 'sectors' => [ + ] + ]; + + $response = static::createClient()->request('POST', $this->addPrefix('source-3') . '/batch', [ + 'headers' => [ + 'API-KEY' => 'token4', + 'APP-NAME' => 'test', + 'accept' => 'application/json', + ], + 'json' => [ + 'data' => [ + $record, + ], + ], + ]); + + $this->assertEquals(201, $response->getStatusCode()); + + $body = json_decode($response->getContent(), TRUE); + $this->assertCount(1, $body['successful']); + $this->assertCount(0, $body['failed']); + $this->assertArrayHasKey(strtolower('src3_cmr_2024_1159_top-sectors'), $body['successful']); + } + } diff --git a/tests/OchaPresenceExternalIdTest.php b/tests/OchaPresenceExternalIdTest.php index f8b1197..a1a0d25 100644 --- a/tests/OchaPresenceExternalIdTest.php +++ b/tests/OchaPresenceExternalIdTest.php @@ -20,7 +20,6 @@ class OchaPresenceExternalIdTest extends ApiTestCase 'year' => '2000', 'external_ids' => [ 'fts_1116', - 'fts_1117', ], ]; @@ -40,6 +39,24 @@ public function testCreateJson(): void ]); $this->assertEquals(201, $response->getStatusCode()); + $body = json_decode($response->getContent(), TRUE); + $this->assertCount(1, $body['external_ids']); + + $this->data['external_ids'][] = 'fts_1117'; + $response = $client->request('PUT', $this->addPrefix('ocha_presence_external_ids/1'), [ + 'headers' => [ + 'API-KEY' => $this->token, + 'APP-NAME' => 'test', + 'accept' => 'application/json', + 'Content-Type' => 'application/json', + ], + 'json' => $this->data, + ]); + + $this->assertEquals(200, $response->getStatusCode()); + $body = json_decode($response->getContent(), TRUE); + $this->assertCount(2, $body['external_ids']); + } public function testCreateLdJson(): void