1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Validator |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2017 pudelek.org.pl |
6
|
|
|
* |
7
|
|
|
* @license MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view source file |
10
|
|
|
* that is bundled with this package in the file LICENSE |
11
|
|
|
* |
12
|
|
|
* @author Marcin Pudełek <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace mrcnpdlk\Validator; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
use mrcnpdlk\Validator\Types\Nrb; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class NrbTest |
22
|
|
|
* |
23
|
|
|
* Polish bank account validator |
24
|
|
|
* |
25
|
|
|
* @package mrcnpdlk\Validator |
26
|
|
|
*/ |
27
|
|
|
class NrbTest extends TestCase |
28
|
|
|
{ |
29
|
|
|
public function testBankAccountValid() |
30
|
|
|
{ |
31
|
|
|
$defNr = '13 1020-2791 2123 5389 7801 0731'; |
32
|
|
|
$res = new Nrb($defNr); |
33
|
|
|
$this->assertEquals('13102027912123538978010731', $res->get()); |
34
|
|
|
$this->assertEquals('102', $res->getBank()); |
35
|
|
|
$this->assertEquals('10202791', $res->getBankDepartment()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testCreate() |
39
|
|
|
{ |
40
|
|
|
$res = Nrb::create('56249006987922476080369247'); |
41
|
|
|
$this->assertEquals('56249006987922476080369247', $res->get()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @expectedException \mrcnpdlk\Validator\Exception |
46
|
|
|
*/ |
47
|
|
|
public function testBankAccountInvalidChecksum() |
48
|
|
|
{ |
49
|
|
|
new Nrb('13102027912123538978010730'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @expectedException \mrcnpdlk\Validator\Exception |
54
|
|
|
*/ |
55
|
|
|
public function testBankAccountInvalidRegex() |
56
|
|
|
{ |
57
|
|
|
new Nrb('131020279121235389780aaa'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @expectedException \mrcnpdlk\Validator\Exception |
62
|
|
|
*/ |
63
|
|
|
public function testBankAccountInvalidBankDepartment() |
64
|
|
|
{ |
65
|
|
|
new Nrb('04 0000 0000 0000 0000 0000 0000'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|