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

Commit

Permalink
Merge branch 'hotfix/110'
Browse files Browse the repository at this point in the history
Closes #110
  • Loading branch information
akrabat committed Jan 29, 2017
2 parents 46fcef5 + 5b9b801 commit c8b36e5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#110](https://github.com/zendframework/zend-validator/pull/110) adds new
Mastercard 2-series BINs

### Deprecated

Expand Down
5 changes: 4 additions & 1 deletion src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class CreditCard extends AbstractValidator
self::LASER => ['6304', '6706', '6771', '6709'],
self::MAESTRO => ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
'6764', '6765', '6766', '6772'],
self::MASTERCARD => ['51', '52', '53', '54', '55'],
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229',
'223', '224', '225', '226', '227', '228', '229',
'23', '24', '25', '26', '271', '2720',
'51', '52', '53', '54', '55'],
self::SOLO => ['6334', '6767'],
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214',
'62215', '62216', '62217', '62218', '62219', '6222', '6223',
Expand Down
38 changes: 38 additions & 0 deletions test/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,44 @@ public function testJcbCard($input, $expected)
$this->assertEquals($expected, $validator->isValid($input));
}

/**
* Data provider
*
* @return string[][]|bool[][]
*/
public function mastercardValues()
{
return [
['4111111111111111', false],
['5011642326344731', false],
['5130982099822729', true],
['2220993834549400', false],
['2221006548643366', true],
['2222007329134574', true],
['2393923057923090', true],
['2484350479254492', true],
['2518224476613101', true],
['2659969950495289', true],
['2720992392889757', true],
['2721008996056187', false],
];
}

/**
* Test mastercard number validity
*
* @dataProvider mastercardValues
*
* @param string $input
* @param bool $expected
*/
public function testMastercardCard($input, $expected)
{
$validator = new CreditCard(['type' => CreditCard::MASTERCARD]);

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

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

0 comments on commit c8b36e5

Please sign in to comment.