Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/etc/zip_codes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</zip>
<zip countryCode="AM">
<codes>
<code id="pattern_1" active="true" example="123456">^[0-9]{6}$</code>
<code id="pattern_1" active="true" example="0010">^[0-9]{4}$</code>
</codes>
</zip>
<zip countryCode="AR">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function getPostcodesDataProvider(): array
{
return [
['AD', 'AD100'], // $countryId, $validPostcode
['AM', '123456'],
['AM', '0010'],
['AR', '1234'], ['AS', '12345'], ['AT', '1234'], ['AU', '1234'], ['AX', '22101'],
['AZ', '1234'], ['AZ', '123456'], ['BA', '12345'], ['BB', 'BB10900'], ['BD', '1234'],
['BE', '1234'], ['BG', '1234'], ['BH', '323'], ['BH', '1209'], ['BM', 'MA 02'],
Expand Down Expand Up @@ -218,4 +218,61 @@ public static function getNlInvalidPostcodesDataProvider(): array
'NL letters only' => ['postCode' => 'ABCD', 'countryId' => 'NL'],
];
}

/**
* Test validate returns true for valid Armenia (AM) postcodes.
*
* Armenia replaced its Soviet-era 6-digit codes with 4-digit codes in 2006.
*
* @param string $postCode
* @param string $countryId
* @return void
*/
#[DataProvider('getAmValidPostcodesDataProvider')]
public function testValidateReturnsTrueForAmValidPostcodes(string $postCode, string $countryId): void
{
$this->assertSame(true, $this->validator->validate($postCode, $countryId));
}

/**
* Data provider for valid AM postcodes.
*
* @return array<string, array{postCode: string, countryId: string}>
*/
public static function getAmValidPostcodesDataProvider(): array
{
return [
'AM lowest code' => ['postCode' => '0001', 'countryId' => 'AM'],
'AM Yerevan code' => ['postCode' => '0010', 'countryId' => 'AM'],
'AM highest code' => ['postCode' => '4204', 'countryId' => 'AM'],
];
}

/**
* Test validate returns false for invalid Armenia (AM) postcodes.
*
* @param string $postCode
* @param string $countryId
* @return void
*/
#[DataProvider('getAmInvalidPostcodesDataProvider')]
public function testValidateReturnsFalseForAmInvalidPostcodes(string $postCode, string $countryId): void
{
$this->assertSame(false, $this->validator->validate($postCode, $countryId));
}

/**
* Data provider for invalid AM postcodes.
*
* @return array<string, array{postCode: string, countryId: string}>
*/
public static function getAmInvalidPostcodesDataProvider(): array
{
return [
'AM legacy six digits' => ['postCode' => '375010', 'countryId' => 'AM'],
'AM too few digits' => ['postCode' => '001', 'countryId' => 'AM'],
'AM too many digits' => ['postCode' => '00100', 'countryId' => 'AM'],
'AM letters' => ['postCode' => 'AM10', 'countryId' => 'AM'],
];
}
}