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

PeselTest::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
use mrcnpdlk\Validator\Types\Pesel;
18
19
class PeselTest extends TestCase
20
{
21 View Code Duplication
    public function testPeselMaleValid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $defNr = '12271402999';
24
        $res   = new Pesel($defNr);
25
        $this->assertEquals('12271402999', $res->get());
26
        $this->assertEquals('2012-07-14', $res->getBirthDate());
27
        $this->assertEquals(Pesel::SEX_M, $res->getSex());
28
        $this->assertEquals(true, $res->getAge() > 3);
29
    }
30
31 View Code Duplication
    public function testPeselFemaleValid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $defNr = '30082916746';
34
        $res   = new Pesel($defNr);
35
        $this->assertEquals('30082916746', $res->get());
36
        $this->assertEquals('1930-08-29', $res->getBirthDate());
37
        $this->assertEquals(Pesel::SEX_F, $res->getSex());
38
        $this->assertEquals(true, $res->getAge() > 86);
39
    }
40
41 View Code Duplication
    public function testPeselOldValid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $defNr = '11880804152';
44
        $res   = new Pesel($defNr);
45
        $this->assertEquals('11880804152', $res->get());
46
        $this->assertEquals('1811-08-08', $res->getBirthDate());
47
        $this->assertEquals(Pesel::SEX_M, $res->getSex());
48
        $this->assertEquals(true, $res->getAge() > 205);
49
    }
50
51
    public function testCreate()
52
    {
53
        $res = Pesel::create('18053118968');
54
        $this->assertEquals('18053118968', $res->get());
55
    }
56
57
    /**
58
     * @expectedException \mrcnpdlk\Validator\Exception
59
     */
60
    public function testPeselInvalidChecksum()
61
    {
62
        new Pesel('12271402990');
63
    }
64
65
    /**
66
     * @expectedException \mrcnpdlk\Validator\Exception
67
     */
68
    public function testPeselInvalidRegex()
69
    {
70
        new Pesel('3008291674');
71
    }
72
73
}
74