Skip to content

Commit 8440e00

Browse files
committed
Merge remote-tracking branch 'tier4/ACP2E-3622' into PR-Tier4-OM-2025-01-24
2 parents e2f6683 + 193853f commit 8440e00

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ValidatorTest.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -31,17 +31,25 @@ protected function setUp(): void
3131
'US' => [
3232
'pattern_1' => ['pattern' => '^[0-9]{5}\-[0-9]{4}$'],
3333
'pattern_2' => ['pattern' => '^[0-9]{5}$']
34+
],
35+
'NL' => [
36+
'pattern_1' => ['pattern' => '^[1-9][0-9]{3}\s?[a-zA-Z]{2}$'],
37+
'pattern_2' => ['pattern' => '^[1-9][0-9]{3}$']
3438
]
3539
];
3640
$this->postcodesConfigMock->expects($this->once())->method('getPostCodes')->willReturn($postCodes);
3741
$this->model = new Validator($this->postcodesConfigMock);
3842
}
3943

40-
public function testValidatePositive()
44+
/**
45+
* @param string $postCode
46+
* @param string $countryId
47+
* @return void
48+
* @dataProvider getCountryPostcodes
49+
*/
50+
public function testValidatePositive(string $postCode, string $countryId): void
4151
{
42-
$postcode = '12345-6789';
43-
$countryId = 'US';
44-
$this->assertTrue($this->model->validate($postcode, $countryId));
52+
$this->assertTrue($this->model->validate($postCode, $countryId));
4553
}
4654

4755
public function testValidateNegative()
@@ -59,4 +67,25 @@ public function testValidateThrowExceptionIfCountryDoesNotExist()
5967
$countryId = 'QQ';
6068
$this->assertFalse($this->model->validate($postcode, $countryId));
6169
}
70+
71+
/**
72+
* @return \string[][]
73+
*/
74+
public static function getCountryPostcodes(): array
75+
{
76+
return [
77+
[
78+
'postCode' => '12345-6789',
79+
'countryId' => 'US'
80+
],
81+
[
82+
'postCode' => '1234',
83+
'countryId' => 'NL'
84+
],
85+
[
86+
'postCode' => '1234AB',
87+
'countryId' => 'NL'
88+
]
89+
];
90+
}
6291
}

app/code/Magento/Directory/etc/zip_codes.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
22
<!--
3-
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Directory:etc/zip_codes.xsd">
99
<zip countryCode="AD">
@@ -569,6 +569,7 @@
569569
<zip countryCode="NL">
570570
<codes>
571571
<code id="pattern_1" active="true" example="1234 AB/1234AB">^[1-9][0-9]{3}\s?[a-zA-Z]{2}$</code>
572+
<code id="pattern_2" active="true" example="1234">^[1-9][0-9]{3}$</code>
572573
</codes>
573574
</zip>
574575
<zip countryCode="NO">

0 commit comments

Comments
 (0)