22
33namespace App \Packages \Domains \Test \Repository ;
44
5+ use App \Models \Country ;
56use App \Packages \Domains \WorldHeritageEntity ;
67use App \Packages \Domains \WorldHeritageRepository ;
8+ use Database \Seeders \CountrySeeder ;
9+ use Database \Seeders \DatabaseSeeder ;
710use Illuminate \Support \Facades \DB ;
811use Tests \TestCase ;
912use App \Models \WorldHeritage ;
10- use Database \Seeders \CountrySeeder ;
1113
1214class WorldHeritageRepository_insertTest extends TestCase
1315{
@@ -32,14 +34,16 @@ private function refresh(): void
3234 if (env ('APP_ENV ' ) === 'testing ' ) {
3335 DB ::connection ('mysql ' )->statement ('SET FOREIGN_KEY_CHECKS=0; ' );
3436 WorldHeritage::truncate ();
37+ Country::truncate ();
38+ DB ::table ('site_state_parties ' )->truncate ();
3539 DB ::connection ('mysql ' )->statement ('SET FOREIGN_KEY_CHECKS=1; ' );
3640 }
3741 }
3842
3943 private static function arraySingleData (): array
4044 {
4145 return [
42- 'unesco_id ' => ' 668 ' ,
46+ 'id ' => 668 ,
4347 'official_name ' => 'Historic Monuments of Ancient Nara ' ,
4448 'name ' => 'Historic Monuments of Ancient Nara ' ,
4549 'name_jp ' => '古都奈良の文化財 ' ,
@@ -57,9 +61,9 @@ private static function arraySingleData(): array
5761 'short_description ' => 'Temples and shrines of the first permanent capital of Japan. ' ,
5862 'image_url ' => '' ,
5963 'unesco_site_url ' => 'https://whc.unesco.org/en/list/668/ ' ,
60- 'state_parties ' => ['JP ' ],
64+ 'state_parties ' => ['JPN ' ],
6165 'state_parties_meta ' => [
62- 'JP ' => [
66+ 'JPN ' => [
6367 'is_primary ' => true ,
6468 'inscription_year ' => 1998 ,
6569 ],
@@ -70,7 +74,7 @@ private static function arraySingleData(): array
7074 private static function arrayMultiData (): array
7175 {
7276 return [
73- 'unesco_id ' => 1133 ,
77+ 'id ' => 1133 ,
7478 'official_name ' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe " ,
7579 'name ' => "Ancient and Primeval Beech Forests " ,
7680 'name_jp ' => null ,
@@ -89,36 +93,35 @@ private static function arrayMultiData(): array
8993 'image_url ' => '' ,
9094 'unesco_site_url ' => 'https://whc.unesco.org/en/list/1133/ ' ,
9195 'state_parties ' => [
92- 'AL ' ,'AT ' ,'BE ' ,'BA ' ,'BG ' ,'HR ' ,'CZ ' ,'FR ' ,'DE ' ,'IT ' ,'MK ' ,'PL ' ,'RO ' ,'SK ' ,'SI ' ,'ES ' ,'CH ' ,'UA '
96+ 'ALB ' ,'AUT ' ,'BEL ' ,'BIH ' ,'BGR ' ,'HRV ' ,'CZE ' ,'FRA ' ,'DEU ' ,'ITA ' ,'MKD ' ,'POL ' ,'ROU ' ,'SVK ' ,'SVN ' ,'ESP ' ,'CHE ' ,'UKR '
9397 ],
9498 'state_parties_meta ' => [
95- 'AL ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
96- 'AT ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
97- 'BE ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
98- 'BA ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
99- 'BG ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
100- 'HR ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
101- 'CZ ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
102- 'FR ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
103- 'DE ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
104- 'IT ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
105- 'MK ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
106- 'PL ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
107- 'RO ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
108- 'SK ' => ['is_primary ' => true , 'inscription_year ' => 2007 ],
109- 'SI ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
110- 'ES ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
111- 'CH ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
112- 'UA ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
99+ 'ALB ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
100+ 'AUT ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
101+ 'BEL ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
102+ 'BIH ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
103+ 'BGR ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
104+ 'HRV ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
105+ 'CZE ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
106+ 'FRA ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
107+ 'DEU ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
108+ 'ITA ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
109+ 'MKD ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
110+ 'POL ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
111+ 'ROU ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
112+ 'SVK ' => ['is_primary ' => true , 'inscription_year ' => 2007 ],
113+ 'SVN ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
114+ 'ESP ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
115+ 'CHE ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
116+ 'UKR ' => ['is_primary ' => false , 'inscription_year ' => 2007 ],
113117 ],
114118 ];
115119 }
116120
117121 public function test_insert_check_single_type (): void
118122 {
119123 $ entity = new WorldHeritageEntity (
120- self ::arraySingleData ()['id ' ] ?? null ,
121- self ::arraySingleData ()['unesco_id ' ],
124+ self ::arraySingleData ()['id ' ],
122125 self ::arraySingleData ()['official_name ' ],
123126 self ::arraySingleData ()['name ' ],
124127 self ::arraySingleData ()['country ' ],
@@ -148,8 +151,7 @@ public function test_insert_check_single_type(): void
148151 public function test_insert_check_single_value (): void
149152 {
150153 $ entity = new WorldHeritageEntity (
151- self ::arraySingleData ()['id ' ] ?? null ,
152- self ::arraySingleData ()['unesco_id ' ],
154+ self ::arraySingleData ()['id ' ],
153155 self ::arraySingleData ()['official_name ' ],
154156 self ::arraySingleData ()['name ' ],
155157 self ::arraySingleData ()['country ' ],
@@ -173,7 +175,7 @@ public function test_insert_check_single_value(): void
173175
174176 $ result = $ this ->repository ->insertHeritage ($ entity );
175177
176- $ this ->assertEquals (self ::arraySingleData ()['unesco_id ' ], $ result ->getUnescoId ());
178+ $ this ->assertEquals (self ::arraySingleData ()['id ' ], $ result ->getId ());
177179 $ this ->assertEquals (self ::arraySingleData ()['official_name ' ], $ result ->getOfficialName ());
178180 $ this ->assertEquals (self ::arraySingleData ()['name ' ], $ result ->getName ());
179181 $ this ->assertEquals (self ::arraySingleData ()['country ' ], $ result ->getCountry ());
@@ -191,14 +193,12 @@ public function test_insert_check_single_value(): void
191193 $ this ->assertEquals (self ::arraySingleData ()['image_url ' ], $ result ->getImageUrl ());
192194 $ this ->assertEquals (self ::arraySingleData ()['unesco_site_url ' ], $ result ->getUnescoSiteUrl ());
193195 $ this ->assertEquals (self ::arraySingleData ()['state_parties ' ], $ result ->getStatePartyCodes ());
194- $ this ->assertEquals (self ::arraySingleData ()['state_parties_meta ' ], $ result ->getStatePartyMeta ());
195196 }
196197
197198 public function test_insert_check_multi_type (): void
198199 {
199200 $ entity = new WorldHeritageEntity (
200- self ::arrayMultiData ()['id ' ] ?? null ,
201- self ::arrayMultiData ()['unesco_id ' ],
201+ self ::arrayMultiData ()['id ' ],
202202 self ::arrayMultiData ()['official_name ' ],
203203 self ::arrayMultiData ()['name ' ],
204204 self ::arrayMultiData ()['country ' ],
@@ -228,8 +228,7 @@ public function test_insert_check_multi_type(): void
228228 public function test_insert_check_multi_value (): void
229229 {
230230 $ entity = new WorldHeritageEntity (
231- self ::arrayMultiData ()['id ' ] ?? null ,
232- self ::arrayMultiData ()['unesco_id ' ],
231+ self ::arrayMultiData ()['id ' ],
233232 self ::arrayMultiData ()['official_name ' ],
234233 self ::arrayMultiData ()['name ' ],
235234 self ::arrayMultiData ()['country ' ],
@@ -253,7 +252,7 @@ public function test_insert_check_multi_value(): void
253252
254253 $ result = $ this ->repository ->insertHeritage ($ entity );
255254
256- $ this ->assertEquals (self ::arrayMultiData ()['unesco_id ' ], $ result ->getUnescoId ());
255+ $ this ->assertEquals (self ::arrayMultiData ()['id ' ], $ result ->getId ());
257256 $ this ->assertEquals (self ::arrayMultiData ()['official_name ' ], $ result ->getOfficialName ());
258257 $ this ->assertEquals (self ::arrayMultiData ()['name ' ], $ result ->getName ());
259258 $ this ->assertEquals (self ::arrayMultiData ()['country ' ], $ result ->getCountry ());
@@ -273,8 +272,8 @@ public function test_insert_check_multi_value(): void
273272 $ this ->assertEqualsCanonicalizing (self ::arrayMultiData ()['state_parties ' ], $ result ->getStatePartyCodes ());
274273 $ this ->assertEquals (self ::arrayMultiData ()['state_parties_meta ' ], $ result ->getStatePartyMeta ());
275274 $ this ->assertEqualsCanonicalizing (
276- self ::arrayMultiData ()['state_parties_meta ' ]['SK ' ],
277- $ entity ->getStatePartyMeta ()['SK ' ]
275+ self ::arrayMultiData ()['state_parties_meta ' ]['SVK ' ],
276+ $ entity ->getStatePartyMeta ()['SVK ' ]
278277 );
279278 }
280279}
0 commit comments