Skip to content

Commit 6428b8c

Browse files
committed
Fix static, test coverage
1 parent dcb5f55 commit 6428b8c

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace 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
{
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
}

0 commit comments

Comments
 (0)