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

Commit

Permalink
Browse files Browse the repository at this point in the history
…endframework#6278-jcb-credit-card-validator-allowed-ranges-update'

Close zendframework/zendframework#6927
Close zendframework/zendframework#6278
  • Loading branch information
Ocramius committed Nov 27, 2014
2 parents 36ac64f + e4e3b3e commit 1c27cbb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/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 test/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 1c27cbb

Please sign in to comment.