Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function arrayData(): array
'latitude' => 0.0,
'longitude' => 0.0,
'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。',
'short_description_jp' => 'あいうえお',
'short_description_ja' => 'あいうえお',
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133',
'state_parties_codes' => [
'ALB','AUT','BEL','BIH','BGR','HRV','CZE','FRA','DEU','ITA','MKD','POL','ROU','SVK','SVN','ESP','CHE','UKR'
Expand Down Expand Up @@ -160,7 +160,7 @@ public function test_check_data_value(): void
$this->assertEquals($this->arrayData()['latitude'], $result->getLatitude());
$this->assertEquals($this->arrayData()['longitude'], $result->getLongitude());
$this->assertEquals($this->arrayData()['short_description'], $result->getShortDescription());
$this->assertEquals($this->arrayData()['short_description_jp'], $result->getShortDescriptionJp());
$this->assertEquals($this->arrayData()['short_description_ja'], $result->getShortDescriptionJp());
$this->assertEquals($this->arrayData()['unesco_site_url'], $result->getUnescoSiteUrl());
$this->assertEquals($expectedCodes, $result->getStatePartyCodes());
$this->assertEquals($orderedExpected, $result->getStatePartiesMeta());
Expand Down
2 changes: 1 addition & 1 deletion src/app/Packages/Domains/WorldHeritageQueryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function getHeritageById(int $id): WorldHeritageDto
'state_party_code' => $statePartyCodes,
'state_party_codes' => $statePartyCodesCompat,
'state_parties_meta' => $statePartiesMeta,
'short_description_ja' => $heritage->descriptions->short_description_ja,
'short_description_jp' => $heritage->descriptions->short_description_ja,
'images' => $imageCollection->toArray(),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function build(array $data): WorldHeritageDto
images: $imageCollection,
imageUrl: $imageUrl ?? null,
unescoSiteUrl: $data['unesco_site_url'] ?? null,
shortDescriptionJp: $data['short_description_jp'] ?? null,
statePartyCodes: $statePartyCodes,
statePartiesMeta: $statePartiesMeta,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static function build(array $data): WorldHeritageDto
images: null,
imageUrl: $thumbnail,
unescoSiteUrl: $data['unesco_site_url'] ?? null,
shortDescriptionJp: $data['short_description_jp'] ?? null,
statePartyCodes: $statePartyCodes,
statePartiesMeta: $statePartiesMeta,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private function arrayData(): array
'latitude' => 0.0,
'longitude' => 0.0,
'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。',
'short_description_jp' => 'あいうえお',
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133',
'state_party_codes' => [
'ALB',
Expand Down Expand Up @@ -123,6 +124,7 @@ public function test_check_return_data_value(): void
$this->assertSame($input['latitude'], $result->getLatitude());
$this->assertSame($input['longitude'], $result->getLongitude());
$this->assertSame($input['short_description'], $result->getShortDescription());
$this->assertSame($input['short_description_jp'], $result->getShortDescriptionJp());
$this->assertSame($input['unesco_site_url'], $result->getUnescoSiteUrl());
$this->assertSame($input['state_party_codes'], $result->getStatePartyCodes());
$this->assertSame($input['state_parties_meta'], $result->getStatePartiesMeta());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,51 +71,49 @@ public function test_build_returns_dto_with_much_country_values(): void
}

private function assertNullOrZeroEquivalent(
float|int|string|null $expected,
float|int|string|null $actual,
mixed $expected,
mixed $actual,
string $fieldName
): void {
$e = $this->normalizeNullableFloat($expected);
$a = $this->normalizeNullableFloat($actual);
$expectedValue = $this->normalizeNullableFloat($expected);
$actualValue = $this->normalizeNullableFloat($actual);

if ($e === null && $a === null) {
if ($expectedValue === null && $actualValue === null) {
$this->assertTrue(true);
return;
}

if ($e === null && $a === 0.0) {
if ($expectedValue === null && $actualValue === 0.0) {
$this->assertTrue(true, "{$fieldName}: expected null, got 0.0 (allowed)");
return;
}

if ($e === 0.0 && $a === null) {
if ($expectedValue === 0.0 && $actualValue === null) {
$this->assertTrue(true, "{$fieldName}: expected 0.0, got null (allowed)");
return;
}

// それ以外は厳密に一致(float比較はデルタ不要なはずの値なのでそのまま)
$this->assertSame($e, $a, "{$fieldName}: expected {$e}, got {$a}");
$this->assertSame($expectedValue, $actualValue, "{$fieldName}: expected {$expectedValue}, got {$actualValue}");
}

private function normalizeNullableFloat(float|int|string|null $v): ?float
private function normalizeNullableFloat(mixed $vaule): ?float
{
if ($v === null) {
if ($vaule === null) {
return null;
}

// 数値文字列も許容(DB/配列が文字列で来るケース対策)
if (is_string($v)) {
$s = trim($v);
if ($s === '') {
if (is_string($vaule)) {
$expectString = trim($vaule);
if ($expectString === '') {
return null;
}
if (!is_numeric($s)) {
if (!is_numeric($expectString)) {
return null;
}
return (float) $s;
return (float) $expectString;
}

return (float) $v;
return (float) $vaule;
}

public static function provideSummaryFactoryCases(): array
Expand Down Expand Up @@ -215,6 +213,7 @@ private function arrayDataNoStateParty(): array
'latitude' => 31.777_777_8,
'longitude' => 35.231_666_7,
'short_description' => "As a holy city for Judaism, Christianity and Islam, Jerusalem has always been of great symbolic importance. Among its 220 historic monuments, the Dome of the Rock stands out: built in the 7th century, it is decorated with beautiful geometric and floral motifs. It is recognized by all three religions as the site of Abraham's sacrifice. The Wailing Wall delimits the quarters of the different religious communities, while the Resurrection rotunda in the Church of the Holy Sepulchre houses Christ's tomb.",
'short_description_jp' => '',
'thumbnail_id' => null,
'unesco_site_url' => null,
'state_parties' => [],
Expand Down Expand Up @@ -269,6 +268,7 @@ private static function arrayDataTransnational(): array
'latitude' => 48.9,
'longitude' => 22.183_333_3,
'short_description' => 'This transnational property includes 93 component parts in 18 countries. Since the end of the last Ice Age, European Beech spread from a few isolated refuge areas in the Alps, Carpathians, Dinarides, Mediterranean and Pyrenees over a short period of a few thousand years in a process that is still ongoing. The successful expansion across a whole continent is related to the tree’s adaptability and tolerance of different climatic, geographical and physical conditions.',
'short_description_jp' => '',
'thumbnail_id' => null,
'unesco_site_url' => null,
'state_parties' => $codes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\WorldHeritage;
use App\Models\Image;

use App\Models\WorldHeritageDescription;
use App\Packages\Features\QueryUseCases\Dto\WorldHeritageDto;
use App\Packages\Features\QueryUseCases\QueryServiceInterface\WorldHeritageQueryServiceInterface;
use App\Packages\Features\QueryUseCases\UseCase\GetWorldHeritageByIdUseCase;
Expand Down Expand Up @@ -40,6 +41,7 @@ private function refresh(): void
Country::truncate();
DB::table('site_state_parties')->truncate();
Image::truncate();
WorldHeritageDescription::truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
}
}
Expand Down Expand Up @@ -71,6 +73,7 @@ private function mockQueryService(): WorldHeritageQueryServiceInterface
null,
null,
$this->arrayData()['unesco_site_url'],
$this->arrayData()['short_description_jp'],
$this->arrayData()['state_party_codes'],
$this->arrayData()['state_parties_meta'],
));
Expand All @@ -97,6 +100,7 @@ private function arrayData(): array
'latitude' => 0.0,
'longitude' => 0.0,
'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。',
'short_description_jp' => 'あいうえお',
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133',
'state_party_codes' => [
'ALB',
Expand Down
Loading