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

RegonTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 48
rs 10
c 3
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testRegonValid() 0 6 1
A testRegonLongValid() 0 7 1
A testCreate() 0 5 1
A testRegonInvalidChecksum() 0 4 1
A testRegonInvalidRegex() 0 4 1
A testRegonEmpty() 0 4 1
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