Completed
Push — master ( 53bd9f...6e9a10 )
by Marcin
01:47
created

NipTest::testNipEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
use mrcnpdlk\Validator\Types\Nip;
18
19
class NipTest extends TestCase
20
{
21
    public function testNipValid()
22
    {
23
        $defNr = '526-10-40-828';
24
        $res   = new Nip($defNr);
25
        $this->assertEquals('5261040828', $res->get());
26
        $this->assertEquals('string', gettype($res->getTaxOffice()));
27
    }
28
29
    public function testIsValid()
30
    {
31
        $this->assertTrue(Nip::isValid('5261040828',false));
32
        $this->assertFalse(Nip::isValid('5261040827',false));
33
    }
34
35
    public function testCreate()
36
    {
37
        $res = Nip::create('7844072717');
38
        $this->assertEquals('7844072717', $res->get());
39
    }
40
41
    /**
42
     * @expectedException \mrcnpdlk\Validator\Exception
43
     */
44
    public function testNipEmpty()
45
    {
46
        new Nip('');
47
    }
48
49
    /**
50
     * @expectedException \mrcnpdlk\Validator\Exception
51
     */
52
    public function testNipInvalidChecksum()
53
    {
54
        new Nip('5261040829');
55
    }
56
57
    /**
58
     * @expectedException \mrcnpdlk\Validator\Exception
59
     */
60
    public function testNipInvalidRegex()
61
    {
62
        new Nip('526104088');
63
    }
64
65
}
66