Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/#6927-#6278-jcb-credit-card-validator-allowed-ra…
Browse files Browse the repository at this point in the history
…nges-update' into develop

Close #6927
Close #6278
Forward port #6927
Forward port #6278
  • Loading branch information
Ocramius committed Nov 27, 2014
2 parents 8d1dab4 + a653da0 commit 56deda7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/Zend/Validator/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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'),
Expand Down
38 changes: 38 additions & 0 deletions tests/ZendTest/Validator/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,44 @@ public function testConstructionWithOptions($input, $expected)
$this->assertEquals($expected, $validator->isValid($input));
}

/**
* Data provider
*
* @return string[][]|bool[][]
*/
public 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
*
* @param string $input
* @param bool $expected
*
* @group 6278
* @group 6927
*/
public function testJcbCard($input, $expected)
{
$validator = new CreditCard(array('type' => CreditCard::JCB));

$this->assertEquals($expected, $validator->isValid($input));
}

/**
* Test an invalid service class
*
Expand Down

0 comments on commit 56deda7

Please sign in to comment.