File tree Expand file tree Collapse file tree 2 files changed +66
-1
lines changed
app/code/Magento/Directory/Setup/Patch/Data
dev/tests/integration/testsuite/Magento/Directory/Model Expand file tree Collapse file tree 2 files changed +66
-1
lines changed Original file line number Diff line number Diff line change 33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Magento \Directory \Setup \Patch \Data ;
@@ -51,12 +50,15 @@ public function apply()
5150 $ this ->moduleDataSetup ->getConnection (),
5251 $ this ->getDataForItaly ()
5352 );
53+
54+ return $ this ;
5455 }
5556
5657 /**
5758 * Italy states data.
5859 *
5960 * @return array
61+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
6062 */
6163 private function getDataForItaly ()
6264 {
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+ declare (strict_types=1 );
7+
8+ namespace Magento \Directory \Model \Country \Postcode \Config ;
9+
10+ use Magento \Directory \Model \Country ;
11+ use Magento \TestFramework \Helper \Bootstrap ;
12+ use PHPUnit \Framework \TestCase ;
13+
14+ class RegionTest extends TestCase
15+ {
16+ /**
17+ * @var Country
18+ */
19+ protected $ country ;
20+
21+ /**
22+ * @inheritDoc
23+ */
24+ public function setUp ()
25+ {
26+ $ this ->country = Bootstrap::getObjectManager ()->create (Country::class);
27+ }
28+
29+ /**
30+ * Verify country has regions.
31+ *
32+ * @var string $countryId
33+ * @dataProvider getCountryIdDataProvider
34+ */
35+ public function testCountryHasRegions ($ countryId )
36+ {
37+ $ country = $ this ->country ->loadByCode ($ countryId );
38+ $ region = $ country ->getRegions ()->getItems ();
39+
40+ $ this ->assertTrue (!empty ($ region ), 'Country ' . $ countryId . ' not have regions ' );
41+ }
42+
43+ /**
44+ * Data provider for testCountryHasRegions
45+ *
46+ * @return array
47+ */
48+ public function getCountryIdDataProvider ():array
49+ {
50+ return [
51+ ['countryId ' => 'US ' ],
52+ ['countryId ' => 'CA ' ],
53+ ['countryId ' => 'CN ' ],
54+ ['countryId ' => 'IN ' ],
55+ ['countryId ' => 'AU ' ],
56+ ['countryId ' => 'BE ' ],
57+ ['countryId ' => 'CO ' ],
58+ ['countryId ' => 'MX ' ],
59+ ['countryId ' => 'PL ' ],
60+ ['countryId ' => 'IT ' ]
61+ ];
62+ }
63+ }
You can’t perform that action at this time.
0 commit comments