File tree 2 files changed +19
-0
lines changed
app/code/Magento/Directory/etc
dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 81
81
<zip countryCode =" CA" >
82
82
<codes >
83
83
<code id =" pattern_1" active =" true" example =" A1B 2C3" >^[a-zA-z]{1}[0-9]{1}[a-zA-z]{1}\s[0-9]{1}[a-zA-z]{1}[0-9]{1}$</code >
84
+ <code id =" pattern_2" active =" true" example =" A1B2C3" >^[a-zA-z]{1}[0-9]{1}[a-zA-z]{1}[0-9]{1}[a-zA-z]{1}[0-9]{1}$</code >
84
85
</codes >
85
86
</zip >
86
87
<zip countryCode =" IC" >
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ public function testPostCodesThrowsExceptionIfCountryDoesNotExist()
42
42
$ this ->validator ->validate ('12345 ' , 'INVALID-CODE ' );
43
43
}
44
44
45
+ public function testInvalidCanadaZipCode () {
46
+ $ resultOnlyDigits = $ this ->validator ->validate ('12345 ' , 'CA ' );
47
+ $ resultMoreCharactersThanNeeded = $ this ->validator ->validate ('A1B2C3D ' , 'CA ' );
48
+ $ resultLessCharactersThanNeeded = $ this ->validator ->validate ('A1B2C ' , 'CA ' );
49
+ $ resultMoreThanOneSpace = $ this ->validator ->validate ('A1B 2C3 ' , 'CA ' );
50
+ $ this ->assertFalse ($ resultOnlyDigits );
51
+ $ this ->assertFalse ($ resultMoreCharactersThanNeeded );
52
+ $ this ->assertFalse ($ resultLessCharactersThanNeeded );
53
+ $ this ->assertFalse ($ resultMoreThanOneSpace );
54
+ }
55
+
56
+ public function testValidCanadaZipCode () {
57
+ $ resultPattern1 = $ this ->validator ->validate ('A1B2C3 ' , 'CA ' );
58
+ $ resultPattern2 = $ this ->validator ->validate ('A1B 2C3 ' , 'CA ' );
59
+ $ this ->assertTrue ($ resultPattern1 );
60
+ $ this ->assertTrue ($ resultPattern2 );
61
+ }
62
+
45
63
/**
46
64
* @return array
47
65
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
You can’t perform that action at this time.
0 commit comments