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 @@ -121,13 +121,12 @@ private static function arraySingleData(): array
private static function arrayMultiData(): array
{
return [
// 既存: ブナ林(ヨーロッパ各地)
[
'unesco_id' => 1133,
'official_name' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe",
'name' => "Ancient and Primeval Beech Forests",
'name_jp' => null,
'country' => 'Slovakia', // 便宜上代表国(実際は汎欧州の連続資産)
'country' => 'Slovakia',
'region' => 'Europe',
'category' => 'natural',
'criteria' => ['ix'],
Expand Down Expand Up @@ -165,8 +164,6 @@ private static function arrayMultiData(): array
'UA' => ['is_primary' => false, 'inscription_year' => 2007],
],
],

// 追加: シルクロード(長安–天山回廊)
[
'unesco_id' => 1442,
'official_name' => "Silk Roads: the Routes Network of Chang'an-Tianshan Corridor",
Expand Down Expand Up @@ -196,8 +193,6 @@ private static function arrayMultiData(): array
];
}



public function test_collection_check_type(): void
{
$collection = new WorldHeritageEntityCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function toArray(): array
'short_description' => $this->getShortDescription(),
'image_url' => $this->getImageUrl(),
'unesco_site_url' => $this->getUnescoSiteUrl(),
'state_parties' => $this->getStatePartyCodes(),
'state_party_codes' => $this->getStatePartyCodes(),
'state_parties_meta' => $this->getStatePartiesMeta(),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function toArray(): array
'bufferZoneHectares' => $heritage->getBufferZoneHectares(),
'shortDescription' => $heritage->getShortDescription(),
'imageUrl' => $heritage->getImageUrl(),
'unescoSiteUrl' => $heritage->getUnescoSiteUrl()
'unescoSiteUrl' => $heritage->getUnescoSiteUrl(),
'statePartyCodes' => $heritage->getStatePartyCodes(),
'statePartiesMeta' => $heritage->getStatePartiesMeta(),
];
}, $this->heritages);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static function build(array $data): WorldHeritageDtoCollection
bufferZoneHectares: $heritage['buffer_zone_hectares'] ?? null,
shortDescription: $heritage['short_description'] ?? null,
imageUrl: $heritage['image_url'] ?? null,
unescoSiteUrl: $heritage['unesco_site_url'] ?? null
unescoSiteUrl: $heritage['unesco_site_url'] ?? null,
statePartyCodes: $heritage['state_parties'] ?? [],
statePartiesMeta: $heritage['state_parties_meta'] ?? []
);
}, $data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private function refresh(): void
private function arrayData(): array
{
return [
'id' => 1,
'unesco_id' => '668',
'official_name' => 'Historic Monuments of Ancient Nara',
'name' => 'Historic Monuments of Ancient Nara',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace App\Packages\Features\QueryUseCases\Tests;

use App\Models\Country;
use App\Models\WorldHeritage;
use App\Packages\Features\QueryUseCases\Dto\WorldHeritageDtoCollection;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
use Mockery;
use Database\Seeders\CountrySeeder;
use App\Packages\Domains\WorldHeritageEntityCollection;
use App\Packages\Domains\WorldHeritageRepositoryInterface;
use App\Packages\Features\QueryUseCases\UseCase\CreateWorldManyHeritagesUseCase;
Expand All @@ -18,6 +20,8 @@ protected function setUp(): void
{
parent::setUp();
$this->refresh();
$seeder = new CountrySeeder();
$seeder->run();
$this->repository = Mockery::mock(WorldHeritageRepositoryInterface::class);
}

Expand All @@ -32,6 +36,8 @@ private function refresh(): void
if (env('APP_ENV') === 'testing') {
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
Comment on lines 37 to 41
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database connection is hardcoded to 'mysql'. Consider using the default connection or making it configurable to support different database types in testing environments.

Suggested change
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

Copilot uses AI. Check for mistakes.
}
}
Expand All @@ -55,91 +61,74 @@ private static function arrayData(): array
return [
[
'id' => 1,
'unesco_id' => '660',
'official_name' => 'Buddhist Monuments in the Horyu-ji Area',
'name' => 'Buddhist Monuments in the Horyu-ji Area',
'name_jp' => '法隆寺地域の仏教建造物',
'country' => 'Japan',
'region' => 'Asia',
'state_party' => 'JP',
'category' => 'cultural',
'criteria' => ['ii', 'iii', 'v'],
'year_inscribed' => 1993,
'area_hectares' => 442.0,
'buffer_zone_hectares' => 320.0,
'unesco_id' => '1133',
'official_name' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe",
'name' => "Ancient and Primeval Beech Forests",
'name_jp' => null,
'country' => 'Slovakia',
'region' => 'Europe',
'category' => 'natural',
'criteria' => ['ix'],
'state_party' => null,
'year_inscribed' => 2007,
'area_hectares' => 99947.81,
'buffer_zone_hectares' => 296275.8,
'is_endangered' => false,
'latitude' => 34.6147,
'longitude' => 135.7355,
'short_description' => "Early Buddhist wooden structures including the world's oldest wooden building.",
'latitude' => 0.0,
'longitude' => 0.0,
'short_description' => 'Transnational serial property of European beech forests illustrating post-glacial expansion and ecological processes across Europe.',
'image_url' => '',
'unesco_site_url' => 'https://whc.unesco.org/en/list/660/',
'created_at' => now(), 'updated_at' => now(),
'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/',
'state_parties' => [
'AL','AT','BE','BA','BG','HR','CZ','FR','DE','IT','MK','PL','RO','SK','SI','ES','CH','UA'
],
'state_parties_meta' => [
'AL' => ['is_primary' => false, 'inscription_year' => 2007],
'AT' => ['is_primary' => false, 'inscription_year' => 2007],
'BE' => ['is_primary' => false, 'inscription_year' => 2007],
'BA' => ['is_primary' => false, 'inscription_year' => 2007],
'BG' => ['is_primary' => false, 'inscription_year' => 2007],
'HR' => ['is_primary' => false, 'inscription_year' => 2007],
'CZ' => ['is_primary' => false, 'inscription_year' => 2007],
'FR' => ['is_primary' => false, 'inscription_year' => 2007],
'DE' => ['is_primary' => false, 'inscription_year' => 2007],
'IT' => ['is_primary' => false, 'inscription_year' => 2007],
'MK' => ['is_primary' => false, 'inscription_year' => 2007],
'PL' => ['is_primary' => false, 'inscription_year' => 2007],
'RO' => ['is_primary' => false, 'inscription_year' => 2007],
'SK' => ['is_primary' => true, 'inscription_year' => 2007],
'SI' => ['is_primary' => false, 'inscription_year' => 2007],
'ES' => ['is_primary' => false, 'inscription_year' => 2007],
'CH' => ['is_primary' => false, 'inscription_year' => 2007],
'UA' => ['is_primary' => false, 'inscription_year' => 2007],
],
],
[
'id' => 2,
'unesco_id' => '661',
'official_name' => 'Himeji-jo',
'name' => 'Himeji-jo',
'name_jp' => '姫路城',
'country' => 'Japan',
'unesco_id' => '1442',
'official_name' => "Silk Roads: the Routes Network of Chang'an-Tianshan Corridor",
'name' => "Silk Roads: Chang'an–Tianshan Corridor",
'name_jp' => 'シルクロード:長安-天山回廊の交易路網',
'country' => 'China, Kazakhstan, Kyrgyzstan',
'region' => 'Asia',
'state_party' => 'JP',
'category' => 'cultural',
'criteria' => ['ii', 'iii', 'v'],
'year_inscribed' => 1993,
'area_hectares' => 442.0,
'buffer_zone_hectares' => 320.0,
'is_endangered' => false,
'latitude' => 34.8394,
'longitude' => 134.6939,
'short_description' => "A masterpiece of Japanese castle architecture in original form.",
'image_url' => '',
'unesco_site_url' => 'https://whc.unesco.org/en/list/661/',
'created_at' => now(), 'updated_at' => now(),
],
[
'id' => 3,
'unesco_id' => '662',
'official_name' => 'Yakushima',
'name' => 'Yakushima',
'name_jp' => '屋久島',
'country' => 'Japan',
'region' => 'Asia',
'state_party' => 'JP',
'category' => 'natural',
'criteria' => ['ii', 'iii', 'v'],
'year_inscribed' => 1993,
'area_hectares' => 442.0,
'buffer_zone_hectares' => 320.0,
'is_endangered' => false,
'latitude' => 30.3581,
'longitude' => 130.546,
'short_description' => "A subtropical island with ancient cedar forests and diverse ecosystems.",
'image_url' => '',
'unesco_site_url' => 'https://whc.unesco.org/en/list/662/',
'created_at' => now(), 'updated_at' => now(),
],
[
'id' => 4,
'unesco_id' => '663',
'official_name' => 'Shirakami-Sanchi',
'name' => 'Shirakami-Sanchi',
'name_jp' => '白神山地',
'country' => 'Japan',
'region' => 'Asia',
'state_party' => 'JP',
'category' => 'natural',
'criteria' => ['ii', 'iii', 'v'],
'year_inscribed' => 1993,
'area_hectares' => 442.0,
'buffer_zone_hectares' => 320.0,
'criteria' => ['ii','iii','vi'],
'state_party' => null,
'year_inscribed' => 2014,
'area_hectares' => 0.0,
'buffer_zone_hectares' => 0.0,
'is_endangered' => false,
'latitude' => 40.5167,
'longitude' => 140.05,
'short_description' => "Pristine beech forest with minimal human impact.",
'latitude' => 0.0,
'longitude' => 0.0,
'short_description' => 'Transnational Silk Road corridor across China, Kazakhstan and Kyrgyzstan illustrating exchange of goods, ideas and beliefs.',
'image_url' => '',
'unesco_site_url' => 'https://whc.unesco.org/en/list/663/',
'created_at' => now(), 'updated_at' => now(),
'unesco_site_url' => 'https://whc.unesco.org/en/list/1442/',
'state_parties' => ['CN','KZ','KG'],
'state_parties_meta' => [
'CN' => ['is_primary' => true, 'inscription_year' => 2014],
'KZ' => ['is_primary' => false, 'inscription_year' => 2014],
'KG' => ['is_primary' => false, 'inscription_year' => 2014],
],
],
];
}
Expand Down
Loading