From 436968a5323c6396ad831b9e349b2fb6d540eb53 Mon Sep 17 00:00:00 2001 From: Alexey Shlaikov Date: Thu, 5 Oct 2017 16:45:03 +0300 Subject: [PATCH 1/4] Added a new type of Russian MIR card. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Алексей Шлайков --- src/CreditCard.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CreditCard.php b/src/CreditCard.php index 6bf514bdd..823f584f7 100644 --- a/src/CreditCard.php +++ b/src/CreditCard.php @@ -31,6 +31,7 @@ class CreditCard extends AbstractValidator const MASTERCARD = 'Mastercard'; const SOLO = 'Solo'; const VISA = 'Visa'; + const MIR = 'Mir'; const CHECKSUM = 'creditcardChecksum'; const CONTENT = 'creditcardContent'; @@ -72,6 +73,7 @@ class CreditCard extends AbstractValidator 8 => self::SOLO, 9 => self::UNIONPAY, 10 => self::VISA, + 11 => self::MIR, ]; /** @@ -91,6 +93,7 @@ class CreditCard extends AbstractValidator self::SOLO => [16, 18, 19], self::UNIONPAY => [16, 17, 18, 19], self::VISA => [13, 16, 19], + self::MIR => [13, 16], ]; /** @@ -122,6 +125,7 @@ class CreditCard extends AbstractValidator '6224', '6225', '6226', '6227', '6228', '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925'], self::VISA => ['4'], + self::MIR => ['2200', '2201', '2202', '2203', '2204'], ]; /** From 6aecdc7351b71538bf0dfbfa0d7e9e48a8eb6a68 Mon Sep 17 00:00:00 2001 From: Alexey Shlaikov Date: Thu, 5 Oct 2017 18:23:51 +0300 Subject: [PATCH 2/4] Tested new card type. --- test/CreditCardTest.php | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/test/CreditCardTest.php b/test/CreditCardTest.php index 29f764345..0173164c3 100644 --- a/test/CreditCardTest.php +++ b/test/CreditCardTest.php @@ -60,7 +60,7 @@ public function testGetMessages() public function testGetSetType() { $validator = new CreditCard(); - $this->assertEquals(11, count($validator->getType())); + $this->assertEquals(12, count($validator->getType())); $validator->setType(CreditCard::MAESTRO); $this->assertEquals([CreditCard::MAESTRO], $validator->getType()); @@ -253,6 +253,45 @@ public function testMastercardCard($input, $expected) $this->assertEquals($expected, $validator->isValid($input)); } + /** + * Data provider + * + * @return string[][]|bool[][] + */ + public function mirValues() + { + return [ + ['3011111111111000', false], + ['2031343323344731', false], + ['2200312032822721', true], + ['2209993834549400', false], + ['2204001882200999', true], + ['2202000312124573', true], + ['2203921957923012', true], + ['2204150479254495', true], + ['2201123406612104', true], + ['2900008996056', false], + ['2201969950494', true], + ['2201342387927', true], + ['2205969950494', false], + ]; + } + + /** + * Test mir card number validity + * + * @dataProvider mirValues + * + * @param string $input + * @param bool $expected + */ + public function testMirCard($input, $expected) + { + $validator = new CreditCard(['type' => CreditCard::MIR]); + + $this->assertEquals($expected, $validator->isValid($input)); + } + /** * Test an invalid service class * From 634680c516ff7690ae3fde7d491af2f162c05e33 Mon Sep 17 00:00:00 2001 From: Alexey Shlaikov Date: Thu, 5 Oct 2017 19:23:00 +0300 Subject: [PATCH 3/4] Edited doc. file. --- doc/book/validators/credit-card.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/book/validators/credit-card.md b/doc/book/validators/credit-card.md index 8cea647f7..e1a7f0ac5 100644 --- a/doc/book/validators/credit-card.md +++ b/doc/book/validators/credit-card.md @@ -33,6 +33,7 @@ The following issuing institutes are accepted: - Solo - Visa - Visa Electron +- Russia Mir > ### Invalid institutes > From 8d3f1192b714533cf839987ac906bb694b9f5979 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 1 Feb 2018 10:51:50 -0600 Subject: [PATCH 4/4] Adds CHANGELOG entry for #203 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de46514e9..36fa31d9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ All notable changes to this project will be documented in this file, in reverse `Zend\Validator\CreditCard`, fixing an issue where users were unable to add new brands as they are created. +- [#203](https://github.com/zendframework/zend-validator/pull/203) adds support + for the new Russian bank card "Mir". + ### Changed - Nothing.