From 9c260ec0afaae93c0d6d1d02e99c6d87a22c52fb Mon Sep 17 00:00:00 2001
From: Dennis Lassiter
Date: Fri, 5 Aug 2016 11:25:21 +0200
Subject: [PATCH 1/3] CreditCard: Added new mastercard 2-series BINs
---
src/CreditCard.php | 5 ++++-
test/CreditCardTest.php | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/src/CreditCard.php b/src/CreditCard.php
index c3a04a433..545ee5c32 100644
--- a/src/CreditCard.php
+++ b/src/CreditCard.php
@@ -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',
diff --git a/test/CreditCardTest.php b/test/CreditCardTest.php
index 8c62e56e8..2ab06c97c 100644
--- a/test/CreditCardTest.php
+++ b/test/CreditCardTest.php
@@ -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
*
From ae04e16d859fc0239b73c5b248911b1bb7cd1332 Mon Sep 17 00:00:00 2001
From: Dennis Lassiter
Date: Fri, 5 Aug 2016 12:15:40 +0200
Subject: [PATCH 2/3] CS fixes as performed by php-cs-fixer
---
src/CreditCard.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CreditCard.php b/src/CreditCard.php
index 545ee5c32..183ae1537 100644
--- a/src/CreditCard.php
+++ b/src/CreditCard.php
@@ -114,7 +114,7 @@ class CreditCard extends AbstractValidator
'6764', '6765', '6766', '6772'],
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229',
'223', '224', '225', '226', '227', '228', '229',
- '23', '24', '25', '26', '271', '2720',
+ '23', '24', '25', '26', '271', '2720',
'51', '52', '53', '54', '55'],
self::SOLO => ['6334', '6767'],
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214',
From 5b9b8013736649d81275cc8b6d5b261a613fc791 Mon Sep 17 00:00:00 2001
From: Rob Allen
Date: Sun, 29 Jan 2017 15:53:09 +0000
Subject: [PATCH 3/3] Update Changelog
- Added #110
---
CHANGELOG.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c22c5359c..607c69769 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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