File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
app/code/Magento/Directory/etc
dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 8181 <zip countryCode =" CA" >
8282 <codes >
8383 <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 >
8485 </codes >
8586 </zip >
8687 <zip countryCode =" IC" >
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ public function testPostCodesThrowsExceptionIfCountryDoesNotExist()
4242 $ this ->validator ->validate ('12345 ' , 'INVALID-CODE ' );
4343 }
4444
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+
4563 /**
4664 * @return array
4765 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
You can’t perform that action at this time.
0 commit comments