Completed
Push — master ( 3ced6b...53bd9f )
by Marcin
01:36
created

NrbTest::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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