Skip to content

Commit 62b3ef0

Browse files
committed
feat: add new property into ViewModel
1 parent e94d93d commit 62b3ef0

5 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/app/Packages/Features/QueryUseCases/Factory/ViewModel/WorldHeritageDetailViewModelFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class WorldHeritageDetailViewModelFactory
1010
{
1111
public static function build(WorldHeritageDto $dto): array
1212
{
13+
1314
return [
1415
'id' => $dto->getId(),
1516
'official_name' => $dto->getOfficialName(),
1617
'name' => $dto->getName(),
17-
'name_jp' => $dto->getNameJp(),
18+
'name_jp' => $dto->getCountryNameJp(),
1819
'country' => $dto->getCountry(),
1920
'region' => $dto->getRegion(),
2021
'category' => $dto->getCategory(),
@@ -27,6 +28,7 @@ public static function build(WorldHeritageDto $dto): array
2728
'longitude' => $dto->getLongitude(),
2829
'short_description' => $dto->getShortDescription(),
2930
'unesco_site_url' => $dto->getUnescoSiteUrl(),
31+
'short_description_jp' => $dto->getShortDescriptionJp(),
3032
'state_party' => $dto->getStateParty(),
3133
'state_party_codes' => $dto->getStatePartyCodes(),
3234
'state_parties_meta' => $dto->getStatePartiesMeta(),

src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageDetailViewModelFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private function arrayData(): array
3838
'latitude' => 0.0,
3939
'longitude' => 0.0,
4040
'short_description' => 'Transnational serial property of European beech forests illustrating post-glacial expansion and ecological processes across Europe.',
41+
'short_description_jp' => 'あいうえお',
4142
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/',
4243
'state_parties' => [
4344
'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
149150
->shouldReceive('getShortDescription')
150151
->andReturn($this->arrayData()['short_description']);
151152

153+
$dto
154+
->shouldReceive('getShortDescriptionJp')
155+
->andReturn($this->arrayData()['short_description_jp']);
156+
152157
$dto
153158
->shouldReceive('getUnescoSiteUrl')
154159
->andReturn($this->arrayData()['unesco_site_url']);

src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageSummaryViewModelFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private function arrayData(): array
4141
'latitude' => 0.0,
4242
'longitude' => 0.0,
4343
'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。',
44+
'short_description_jp' => 'あいうえお',
4445
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133',
4546
'thumbnail_url' => 'https://example.com/thumbnail.jpg',
4647
'state_parties_codes' => [
@@ -146,6 +147,9 @@ private function mockDto(): WorldHeritageDto
146147
$mock->shouldReceive('getCountryNameJp')
147148
->andReturn($this->arrayData()['country_name_jp']);
148149

150+
$mock->shouldReceive('getShortDescriptionJp')
151+
->andReturn($this->arrayData()['short_description_jp']);
152+
149153
$mock->shouldReceive('getPrimaryStatePartyCode')
150154
->andReturn($this->arrayData()['state_parties_codes'][4]);
151155

@@ -198,6 +202,7 @@ public function test_check_view_model_value(): void
198202
$this->assertEquals($this->arrayData()['area_hectares'], $resultArray['area_hectares']);
199203
$this->assertEquals($this->arrayData()['buffer_zone_hectares'], $resultArray['buffer_zone_hectares']);
200204
$this->assertEquals($this->arrayData()['short_description'], $resultArray['short_description']);
205+
$this->assertEquals($this->arrayData()['short_description_jp'], $resultArray['short_description_jp']);
201206
$this->assertEquals($this->arrayData()['state_parties_codes'], $resultArray['state_party_codes']);
202207
$this->assertEquals($this->arrayData()['state_parties_meta'], $resultArray['state_parties_meta']);
203208
$this->assertEquals($this->arrayData()['thumbnail_url'], $resultArray['thumbnail_url']);

src/app/Packages/Features/QueryUseCases/Tests/ViewModel/WorldHeritageViewModelCollectionFactoryTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private function arrayData(): array
4242
'latitude' => 0.0,
4343
'longitude' => 0.0,
4444
'short_description' => 'Transnational serial property of European beech forests illustrating post-glacial expansion and ecological processes across Europe.',
45+
'short_description_jp' => 'あいうえお',
4546
'thumbnail_url' => 'https://example.com/en/list/1133/',
4647
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/',
4748
'state_parties' => [
@@ -86,6 +87,7 @@ private function arrayData(): array
8687
'latitude' => 0.0,
8788
'longitude' => 0.0,
8889
'short_description' => 'Transnational Silk Road corridor across China, Kazakhstan and Kyrgyzstan illustrating exchange of goods, ideas and beliefs.',
90+
'short_description_jp' => 'あいうえお',
8991
'thumbnail_url' => 'https://example.com/en/list/1442/',
9092
'unesco_site_url' => 'https://whc.unesco.org/en/list/1442/',
9193
'state_parties' => ['CN','KZ','KG'],
@@ -131,6 +133,7 @@ private function mockDtoCollection(): WorldHeritageDtoCollection
131133
images: null,
132134
imageUrl: $thumbnail,
133135
unescoSiteUrl: $data['unesco_site_url'] ?? null,
136+
shortDescriptionJp: $data['short_description_jp'] ?? null,
134137
statePartyCodes: $data['state_party_codes'] ?? ($data['state_parties'] ?? []),
135138
statePartiesMeta: $data['state_parties_meta'] ?? []
136139
);
@@ -178,6 +181,7 @@ public function test_view_model_collection_check_value(): void
178181
$this->assertEquals($this->arrayData()[$key]['latitude'], $value['latitude']);
179182
$this->assertEquals($this->arrayData()[$key]['longitude'], $value['longitude']);
180183
$this->assertEquals($this->arrayData()[$key]['short_description'], $value['short_description']);
184+
$this->assertEquals($this->arrayData()[$key]['short_description_jp'], $value['short_description_jp']);
181185
$this->assertEquals($this->arrayData()[$key]['thumbnail_url'], $value['thumbnail_url']);
182186
$this->assertSame($expectedCodes, $value['state_party_codes']);
183187
$this->assertEquals($this->arrayData()[$key]['state_parties_meta'], $value['state_parties_meta']);

src/app/Packages/Features/QueryUseCases/ViewModel/WorldHeritageViewModel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ public function getImages(): array
125125
return $this->dto->getImages();
126126
}
127127

128+
public function getShortDescriptionJp(): ?string
129+
{
130+
return $this->dto->getShortDescriptionJp();
131+
}
132+
128133
public function toArray(): array
129134
{
130135
return [
@@ -146,6 +151,7 @@ public function toArray(): array
146151
'buffer_zone_hectares' => $this->getBufferZoneHectares(),
147152
'short_description' => $this->getShortDescription(),
148153
'unesco_site_url' => $this->getUnescoSiteUrl(),
154+
'short_description_jp' => $this->getShortDescriptionJp(),
149155
'state_party_codes' => $this->getStatePartyCodes(),
150156
'state_parties_meta' => $this->getStatePartiesMeta(),
151157
'primary_state_party_code' => $this->getPrimaryStatePartyCode(),

0 commit comments

Comments
 (0)