diff --git a/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php b/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php index bfdc8a3..d849d56 100644 --- a/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php +++ b/src/app/Packages/Features/QueryUseCases/Dto/WorldHeritageDto.php @@ -115,6 +115,11 @@ public function getShortDescription(): ?string return $this->shortDescription; } + public function getShortDescriptionJp(): ?string + { + return $this->shortDescriptionJp; + } + public function getUnescoSiteUrl(): ?string { return $this->unescoSiteUrl; @@ -179,11 +184,6 @@ public function getThumbnailUrl(): ?string return $this->imageUrl?->getUrl(); } - public function getShortDescriptionJp(): ?string - { - return $this->shortDescriptionJp; - } - public function toArray(): array { $value = [ diff --git a/src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php b/src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php index 0821952..86818b7 100644 --- a/src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php +++ b/src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php @@ -10,11 +10,12 @@ class WorldHeritageDetailViewModelFactory { public static function build(WorldHeritageDto $dto): array { + return [ 'id' => $dto->getId(), 'official_name' => $dto->getOfficialName(), 'name' => $dto->getName(), - 'name_jp' => $dto->getNameJp(), + 'name_jp' => $dto->getCountryNameJp(), 'country' => $dto->getCountry(), 'region' => $dto->getRegion(), 'category' => $dto->getCategory(), @@ -27,6 +28,7 @@ public static function build(WorldHeritageDto $dto): array 'longitude' => $dto->getLongitude(), 'short_description' => $dto->getShortDescription(), 'unesco_site_url' => $dto->getUnescoSiteUrl(), + 'short_description_jp' => $dto->getShortDescriptionJp(), 'state_party' => $dto->getStateParty(), 'state_party_codes' => $dto->getStatePartyCodes(), 'state_parties_meta' => $dto->getStatePartiesMeta(), diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php index 2f19048..834b175 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php @@ -38,6 +38,7 @@ private function arrayData(): array 'latitude' => 0.0, 'longitude' => 0.0, 'short_description' => 'Transnational serial property of European beech forests illustrating post-glacial expansion and ecological processes across Europe.', + 'short_description_jp' => 'あいうえお', 'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/', 'state_parties' => [ 'ALB','AUT','BEL','BIH','BGR','HRV','CZE','FRA','DEU','ITA','MKD','POL','ROU','SVK','SVN','ESP','CHE','UKR' @@ -149,6 +150,10 @@ private function mockDto(): WorldHeritageDto ->shouldReceive('getShortDescription') ->andReturn($this->arrayData()['short_description']); + $dto + ->shouldReceive('getShortDescriptionJp') + ->andReturn($this->arrayData()['short_description_jp']); + $dto ->shouldReceive('getUnescoSiteUrl') ->andReturn($this->arrayData()['unesco_site_url']); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php index 9d5d955..7b235c1 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php @@ -41,6 +41,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', 'thumbnail_url' => 'https://example.com/thumbnail.jpg', 'state_parties_codes' => [ @@ -146,6 +147,9 @@ private function mockDto(): WorldHeritageDto $mock->shouldReceive('getCountryNameJp') ->andReturn($this->arrayData()['country_name_jp']); + $mock->shouldReceive('getShortDescriptionJp') + ->andReturn($this->arrayData()['short_description_jp']); + $mock->shouldReceive('getPrimaryStatePartyCode') ->andReturn($this->arrayData()['state_parties_codes'][4]); @@ -198,6 +202,7 @@ public function test_check_view_model_value(): void $this->assertEquals($this->arrayData()['area_hectares'], $resultArray['area_hectares']); $this->assertEquals($this->arrayData()['buffer_zone_hectares'], $resultArray['buffer_zone_hectares']); $this->assertEquals($this->arrayData()['short_description'], $resultArray['short_description']); + $this->assertEquals($this->arrayData()['short_description_jp'], $resultArray['short_description_jp']); $this->assertEquals($this->arrayData()['state_parties_codes'], $resultArray['state_party_codes']); $this->assertEquals($this->arrayData()['state_parties_meta'], $resultArray['state_parties_meta']); $this->assertEquals($this->arrayData()['thumbnail_url'], $resultArray['thumbnail_url']); diff --git a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php index 65f9b6c..e167c27 100644 --- a/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php +++ b/src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php @@ -42,6 +42,7 @@ private function arrayData(): array 'latitude' => 0.0, 'longitude' => 0.0, 'short_description' => 'Transnational serial property of European beech forests illustrating post-glacial expansion and ecological processes across Europe.', + 'short_description_jp' => 'あいうえお', 'thumbnail_url' => 'https://example.com/en/list/1133/', 'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/', 'state_parties' => [ @@ -86,6 +87,7 @@ private function arrayData(): array 'latitude' => 0.0, 'longitude' => 0.0, 'short_description' => 'Transnational Silk Road corridor across China, Kazakhstan and Kyrgyzstan illustrating exchange of goods, ideas and beliefs.', + 'short_description_jp' => 'あいうえお', 'thumbnail_url' => 'https://example.com/en/list/1442/', 'unesco_site_url' => 'https://whc.unesco.org/en/list/1442/', 'state_parties' => ['CN','KZ','KG'], @@ -131,6 +133,7 @@ private function mockDtoCollection(): WorldHeritageDtoCollection images: null, imageUrl: $thumbnail, unescoSiteUrl: $data['unesco_site_url'] ?? null, + shortDescriptionJp: $data['short_description_jp'] ?? null, statePartyCodes: $data['state_party_codes'] ?? ($data['state_parties'] ?? []), statePartiesMeta: $data['state_parties_meta'] ?? [] ); @@ -178,6 +181,7 @@ public function test_view_model_collection_check_value(): void $this->assertEquals($this->arrayData()[$key]['latitude'], $value['latitude']); $this->assertEquals($this->arrayData()[$key]['longitude'], $value['longitude']); $this->assertEquals($this->arrayData()[$key]['short_description'], $value['short_description']); + $this->assertEquals($this->arrayData()[$key]['short_description_jp'], $value['short_description_jp']); $this->assertEquals($this->arrayData()[$key]['thumbnail_url'], $value['thumbnail_url']); $this->assertSame($expectedCodes, $value['state_party_codes']); $this->assertEquals($this->arrayData()[$key]['state_parties_meta'], $value['state_parties_meta']); diff --git a/src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModel.php b/src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModel.php index 1780644..4dd77cc 100644 --- a/src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModel.php +++ b/src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModel.php @@ -125,6 +125,11 @@ public function getImages(): array return $this->dto->getImages(); } + public function getShortDescriptionJp(): ?string + { + return $this->dto->getShortDescriptionJp(); + } + public function toArray(): array { return [ @@ -146,6 +151,7 @@ public function toArray(): array 'buffer_zone_hectares' => $this->getBufferZoneHectares(), 'short_description' => $this->getShortDescription(), 'unesco_site_url' => $this->getUnescoSiteUrl(), + 'short_description_jp' => $this->getShortDescriptionJp(), 'state_party_codes' => $this->getStatePartyCodes(), 'state_parties_meta' => $this->getStatePartiesMeta(), 'primary_state_party_code' => $this->getPrimaryStatePartyCode(), diff --git a/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php b/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php index b23f66f..29d6426 100644 --- a/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php +++ b/src/app/Packages/Features/Tests/GetWorldHeritageByIdTest.php @@ -74,6 +74,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_parties_codes' => [ 'ALB','AUT','BEL','BIH','BGR','HRV','CZE','FRA','DEU','ITA','MKD','POL','ROU','SVK','SVN','ESP','CHE','UKR' @@ -157,6 +158,7 @@ public function test_feature_test_ok(): void 'latitude', 'longitude', 'short_description', + 'short_description_jp', 'images' => [ '*' => [ 'id', diff --git a/src/app/Packages/Features/Tests/GetWorldHeritagesTest.php b/src/app/Packages/Features/Tests/GetWorldHeritagesTest.php index cca4cd6..41f7a96 100644 --- a/src/app/Packages/Features/Tests/GetWorldHeritagesTest.php +++ b/src/app/Packages/Features/Tests/GetWorldHeritagesTest.php @@ -3,6 +3,7 @@ namespace App\Packages\Features\Tests; use App\Models\Image; +use App\Models\WorldHeritageDescription; use App\Packages\Domains\Ports\Dto\HeritageSearchResult; use App\Packages\Domains\Ports\WorldHeritageSearchPort; use Database\Seeders\DatabaseSeeder; @@ -44,6 +45,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;'); } } @@ -70,6 +72,7 @@ private static function arrayData(): array 'latitude' => 34.8394, 'longitude' => 134.6939, 'short_description' => "白鷺城の名で知られる城郭建築の傑作。天守群と縄張りが良好に保存される。", + 'short_description_jp' => 'あいうえお', 'unesco_site_url' => 'https://whc.unesco.org/en/list/661', ], [ @@ -90,6 +93,7 @@ private static function arrayData(): array 'latitude' => null, 'longitude' => null, 'short_description' => "巨樹・照葉樹林に代表される生態系と景観が特筆される島。", + 'short_description_jp' => 'あいうえお', 'unesco_site_url' => 'https://whc.unesco.org/en/list/662', ], [ @@ -110,6 +114,7 @@ private static function arrayData(): array 'latitude' => null, 'longitude' => null, 'short_description' => "日本最大級のブナ天然林を中心とする山地生態系。", + 'short_description_jp' => 'あいうえお', 'unesco_site_url' => 'https://whc.unesco.org/en/list/663', ], [ @@ -130,6 +135,7 @@ private static function arrayData(): array 'latitude' => 0.0, 'longitude' => 0.0, 'short_description' => '中国・カザフスタン・キルギスにまたがるオアシス都市や遺跡群で構成され、東西交流の歴史を物証する文化遺産群。', + 'short_description_jp' => 'あいうえお', 'unesco_site_url' => 'https://whc.unesco.org/en/list/1442', ] ]; @@ -163,6 +169,7 @@ public function test_feature_api_ok_with_ids(): void 'area_hectares', 'buffer_zone_hectares', 'short_description', + 'short_description_jp', 'unesco_site_url', 'state_party_codes', 'state_parties_meta', diff --git a/src/app/Packages/Features/Tests/SearchWorldHeritagesTest.php b/src/app/Packages/Features/Tests/SearchWorldHeritagesTest.php index 7a524c4..abd9fc7 100644 --- a/src/app/Packages/Features/Tests/SearchWorldHeritagesTest.php +++ b/src/app/Packages/Features/Tests/SearchWorldHeritagesTest.php @@ -5,6 +5,7 @@ use App\Models\Country; use App\Models\Image; use App\Models\WorldHeritage; +use App\Models\WorldHeritageDescription; use App\Packages\Domains\Ports\Dto\HeritageSearchResult; use App\Packages\Domains\Ports\WorldHeritageSearchPort; @@ -47,6 +48,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;'); }