From 83c12a199417fddae64272d4ba5579ef0cbb5a62 Mon Sep 17 00:00:00 2001 From: "r.bastide" Date: Wed, 26 Nov 2014 01:36:51 +0100 Subject: [PATCH 1/6] #6278 Add test for JCB credit card (length = 15 or 16) --- tests/ZendTest/Validator/CreditCardTest.php | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/ZendTest/Validator/CreditCardTest.php b/tests/ZendTest/Validator/CreditCardTest.php index d0467286d90..ae689d3a1f5 100644 --- a/tests/ZendTest/Validator/CreditCardTest.php +++ b/tests/ZendTest/Validator/CreditCardTest.php @@ -175,6 +175,37 @@ public function testConstructionWithOptions($input, $expected) $this->assertEquals($expected, $validator->isValid($input)); } + public static function jcbValues() + { + return array( + array('3566003566003566', true), + array('3528000000000007', true), + array('3528000000000007', true), + array('3528000000000007', true), + array('3088185545477406', false), + array('3158854390756173', false), + array('3088936920428541', false), + array('213193692042852', true), + array('180012362524156', true), + ); + } + + /** + * Test JCB number validity + * + * @dataProvider jcbValues + */ + public function testJcbCard($input, $expected) + { + $validator = new CreditCard( + array( + 'type' => CreditCard::JCB + ) + ); + + $this->assertEquals($expected, $validator->isValid($input)); + } + /** * Test an invalid service class * From fd96565b6938b3cdd0216ff44bf919c95f8991b2 Mon Sep 17 00:00:00 2001 From: "r.bastide" Date: Wed, 26 Nov 2014 01:37:58 +0100 Subject: [PATCH 2/6] #6278 Allow JCB credit card number to be 15 digits long --- library/Zend/Validator/CreditCard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Zend/Validator/CreditCard.php b/library/Zend/Validator/CreditCard.php index e54a17c2e4f..a92d49aa14b 100644 --- a/library/Zend/Validator/CreditCard.php +++ b/library/Zend/Validator/CreditCard.php @@ -84,7 +84,7 @@ class CreditCard extends AbstractValidator self::DINERS_CLUB => array(14), self::DINERS_CLUB_US => array(16), self::DISCOVER => array(16), - self::JCB => array(16), + self::JCB => array(15, 16), self::LASER => array(16, 17, 18, 19), self::MAESTRO => array(12, 13, 14, 15, 16, 17, 18, 19), self::MASTERCARD => array(16), @@ -108,7 +108,7 @@ class CreditCard extends AbstractValidator '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925', '644', '645', '646', '647', '648', '649', '65'), - self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'), + self::JCB => array('1800', '2131', '3528', '3529', '353', '354', '355', '356', '357', '358'), self::LASER => array('6304', '6706', '6771', '6709'), self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766'), From c348e0faa2b9ee1ac946cbe032fee70480d9cd4a Mon Sep 17 00:00:00 2001 From: Romain Bastide Date: Wed, 26 Nov 2014 01:36:51 +0100 Subject: [PATCH 3/6] #6278 Add test for JCB credit card (length = 15 or 16) --- tests/ZendTest/Validator/CreditCardTest.php | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/ZendTest/Validator/CreditCardTest.php b/tests/ZendTest/Validator/CreditCardTest.php index d0467286d90..ae689d3a1f5 100644 --- a/tests/ZendTest/Validator/CreditCardTest.php +++ b/tests/ZendTest/Validator/CreditCardTest.php @@ -175,6 +175,37 @@ public function testConstructionWithOptions($input, $expected) $this->assertEquals($expected, $validator->isValid($input)); } + public static function jcbValues() + { + return array( + array('3566003566003566', true), + array('3528000000000007', true), + array('3528000000000007', true), + array('3528000000000007', true), + array('3088185545477406', false), + array('3158854390756173', false), + array('3088936920428541', false), + array('213193692042852', true), + array('180012362524156', true), + ); + } + + /** + * Test JCB number validity + * + * @dataProvider jcbValues + */ + public function testJcbCard($input, $expected) + { + $validator = new CreditCard( + array( + 'type' => CreditCard::JCB + ) + ); + + $this->assertEquals($expected, $validator->isValid($input)); + } + /** * Test an invalid service class * From 083e57a4370aab1ac6740688bbdbf4dabed42216 Mon Sep 17 00:00:00 2001 From: Romain Bastide Date: Wed, 26 Nov 2014 01:37:58 +0100 Subject: [PATCH 4/6] #6278 Allow JCB credit card number to be 15 digits long --- library/Zend/Validator/CreditCard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Zend/Validator/CreditCard.php b/library/Zend/Validator/CreditCard.php index e54a17c2e4f..a92d49aa14b 100644 --- a/library/Zend/Validator/CreditCard.php +++ b/library/Zend/Validator/CreditCard.php @@ -84,7 +84,7 @@ class CreditCard extends AbstractValidator self::DINERS_CLUB => array(14), self::DINERS_CLUB_US => array(16), self::DISCOVER => array(16), - self::JCB => array(16), + self::JCB => array(15, 16), self::LASER => array(16, 17, 18, 19), self::MAESTRO => array(12, 13, 14, 15, 16, 17, 18, 19), self::MASTERCARD => array(16), @@ -108,7 +108,7 @@ class CreditCard extends AbstractValidator '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925', '644', '645', '646', '647', '648', '649', '65'), - self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'), + self::JCB => array('1800', '2131', '3528', '3529', '353', '354', '355', '356', '357', '358'), self::LASER => array('6304', '6706', '6771', '6709'), self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766'), From c2f2f4777eadb38ae30a53131973676725111833 Mon Sep 17 00:00:00 2001 From: Romain Bastide Date: Wed, 26 Nov 2014 22:13:25 +0100 Subject: [PATCH 5/6] Remove static in dataProvider declaration --- tests/ZendTest/Validator/CreditCardTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ZendTest/Validator/CreditCardTest.php b/tests/ZendTest/Validator/CreditCardTest.php index ae689d3a1f5..3e13fdc15c2 100644 --- a/tests/ZendTest/Validator/CreditCardTest.php +++ b/tests/ZendTest/Validator/CreditCardTest.php @@ -175,7 +175,7 @@ public function testConstructionWithOptions($input, $expected) $this->assertEquals($expected, $validator->isValid($input)); } - public static function jcbValues() + public function jcbValues() { return array( array('3566003566003566', true), From d6731b86af13a1354aa74a8003a6bff3a115d85d Mon Sep 17 00:00:00 2001 From: Romain Bastide Date: Wed, 26 Nov 2014 22:41:49 +0100 Subject: [PATCH 6/6] Add group issue annotation --- tests/ZendTest/Validator/CreditCardTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ZendTest/Validator/CreditCardTest.php b/tests/ZendTest/Validator/CreditCardTest.php index 3e13fdc15c2..26eed6bf5be 100644 --- a/tests/ZendTest/Validator/CreditCardTest.php +++ b/tests/ZendTest/Validator/CreditCardTest.php @@ -194,6 +194,7 @@ public function jcbValues() * Test JCB number validity * * @dataProvider jcbValues + * @group issue-6278 */ public function testJcbCard($input, $expected) {