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

RegonTest::testRegonEmpty()   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\Regon;
18
19
class RegonTest extends TestCase
20
{
21
    public function testRegonValid()
22
    {
23
        $defNr = '331501';
24
        $res   = new Regon($defNr);
25
        $this->assertEquals('000331501', $res->get());
26
    }
27
28
    public function testRegonLongValid()
29
    {
30
        $defNr = '47051837100020';
31
        $res   = new Regon($defNr);
32
        $this->assertEquals('470518371', $res->getShort());
33
        $this->assertEquals('47051837100020', $res->getLong());
34
    }
35
36
    public function testCreate()
37
    {
38
        $res = Regon::create('45700482854889');
39
        $this->assertEquals('45700482854889', $res->get());
40
    }
41
42
    /**
43
     * @expectedException \mrcnpdlk\Validator\Exception
44
     */
45
    public function testRegonInvalidChecksum()
46
    {
47
        new Regon('000331502');
48
    }
49
50
    /**
51
     * @expectedException \mrcnpdlk\Validator\Exception
52
     */
53
    public function testRegonInvalidRegex()
54
    {
55
        new Regon('0003315021');
56
    }
57
58
    /**
59
     * @expectedException \mrcnpdlk\Validator\Exception
60
     */
61
    public function testRegonEmpty()
62
    {
63
        new Regon('');
64
    }
65
66
}
67