@@ -42,24 +42,35 @@ 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 );
45
+ /**
46
+ * @dataProvider getCanadaInvalidPostCodes
47
+ */
48
+ public function testInvalidCanadaZipCode ($ countryId , $ invalidPostCode ) {
49
+ $ this ->assertFalse ($ this ->validator ->validate ($ invalidPostCode , $ countryId ));
54
50
}
55
51
52
+ /**
53
+ *
54
+ */
56
55
public function testValidCanadaZipCode () {
57
56
$ resultPattern1 = $ this ->validator ->validate ('A1B2C3 ' , 'CA ' );
58
57
$ resultPattern2 = $ this ->validator ->validate ('A1B 2C3 ' , 'CA ' );
59
58
$ this ->assertTrue ($ resultPattern1 );
60
59
$ this ->assertTrue ($ resultPattern2 );
61
60
}
62
61
62
+ /**
63
+ * @return array
64
+ */
65
+ public function getCanadaInvalidPostCodes () {
66
+ return [
67
+ ['countryId ' => 'CA ' , 'postcode ' => '12345 ' ],
68
+ ['countryId ' => 'CA ' , 'postcode ' => 'A1B2C3D ' ],
69
+ ['countryId ' => 'CA ' , 'postcode ' => 'A1B2C ' ],
70
+ ['countryId ' => 'CA ' , 'postcode ' => 'A1B 2C3 ' ],
71
+ ];
72
+ }
73
+
63
74
/**
64
75
* @return array
65
76
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
0 commit comments