@@ -42,24 +42,35 @@ 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 );
45+ /**
46+ * @dataProvider getCanadaInvalidPostCodes
47+ */
48+ public function testInvalidCanadaZipCode ($ countryId , $ invalidPostCode ) {
49+ $ this ->assertFalse ($ this ->validator ->validate ($ invalidPostCode , $ countryId ));
5450 }
5551
52+ /**
53+ *
54+ */
5655 public function testValidCanadaZipCode () {
5756 $ resultPattern1 = $ this ->validator ->validate ('A1B2C3 ' , 'CA ' );
5857 $ resultPattern2 = $ this ->validator ->validate ('A1B 2C3 ' , 'CA ' );
5958 $ this ->assertTrue ($ resultPattern1 );
6059 $ this ->assertTrue ($ resultPattern2 );
6160 }
6261
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+
6374 /**
6475 * @return array
6576 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
0 commit comments