From 66f304813b2be376115e314cee42d33208dca5be Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 20 Apr 2026 22:16:07 +0900 Subject: [PATCH 1/4] feat: add short_description_jp property and update related logic --- .../Dto/WorldHeritageDetailFactory.php | 1 + .../Dto/WorldHeritageSummaryFactory.php | 1 + .../Dto/WorldHeritageDtoDetailFactoryTest.php | 2 ++ .../WorldHeritageDtoSummaryFactoryTest.php | 36 +++++++++---------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php index 72a2b9d..7ad069b 100644 --- a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php +++ b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageDetailFactory.php @@ -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, ); diff --git a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php index 0f868f6..8735972 100644 --- a/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php +++ b/src/app/Packages/Features/QueryUseCases/Factory/Dto/WorldHeritageSummaryFactory.php @@ -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, ); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php index 17b602c..43d7cfd 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoDetailFactoryTest.php @@ -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', @@ -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()); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php index 71fc93a..77719c1 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/Dto/WorldHeritageDtoSummaryFactoryTest.php @@ -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 @@ -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' => [], @@ -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, From b98110e1437f8ba635a563ea45a4c09f57cd2c0d Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 20 Apr 2026 22:21:11 +0900 Subject: [PATCH 2/4] feat: add short_description_jp property in usecase test --- .../Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php b/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php index 236a303..2285ac0 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/UseCase/GetWorldHeritageByIdUseCaseTest.php @@ -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; @@ -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;'); } } @@ -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'], )); @@ -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', From 739eb83115098d57c832fc74ed234d2c3dda0f26 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 20 Apr 2026 22:47:40 +0900 Subject: [PATCH 3/4] fix: delete redundant property --- .../Test/QueryService/WorldHeritageQueryService_getByIdTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php index 13dbeca..d962877 100644 --- a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php +++ b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php @@ -160,7 +160,6 @@ 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()['unesco_site_url'], $result->getUnescoSiteUrl()); $this->assertEquals($expectedCodes, $result->getStatePartyCodes()); $this->assertEquals($orderedExpected, $result->getStatePartiesMeta()); From f543920782b8a8294aaaab337b93cba93f287e68 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Mon, 20 Apr 2026 22:52:05 +0900 Subject: [PATCH 4/4] fix: failed test --- .../QueryService/WorldHeritageQueryService_getByIdTest.php | 3 ++- src/app/Packages/Domains/WorldHeritageQueryService.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php index d962877..19f496d 100644 --- a/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php +++ b/src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php @@ -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' @@ -160,6 +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_ja'], $result->getShortDescriptionJp()); $this->assertEquals($this->arrayData()['unesco_site_url'], $result->getUnescoSiteUrl()); $this->assertEquals($expectedCodes, $result->getStatePartyCodes()); $this->assertEquals($orderedExpected, $result->getStatePartiesMeta()); diff --git a/src/app/Packages/Domains/WorldHeritageQueryService.php b/src/app/Packages/Domains/WorldHeritageQueryService.php index d2933f2..1e74867 100644 --- a/src/app/Packages/Domains/WorldHeritageQueryService.php +++ b/src/app/Packages/Domains/WorldHeritageQueryService.php @@ -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(), ]); }