1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Tin\Test; |
4
|
|
|
|
5
|
|
|
use LeKoala\Tin\TINValid; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Credits to czechphp for real test data |
10
|
|
|
* |
11
|
|
|
* @link https://github.com/czechphp/national-identification-number-validator/blob/master/Tests/NationalIdentificationNumberValidatorTest.php |
12
|
|
|
*/ |
13
|
|
|
class CZAlgorithmTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @dataProvider validProvider |
17
|
|
|
* |
18
|
|
|
* @param string $value |
19
|
|
|
*/ |
20
|
|
|
public function testValid(string $value) |
21
|
|
|
{ |
22
|
|
|
$this->assertTrue( |
23
|
|
|
TINValid::checkTIN('cz', $value) |
24
|
|
|
); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
public function validProvider() |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
|
|
['000101999'], // spec1 |
34
|
|
|
['000101999C'], // spec2 |
35
|
|
|
['103224/0000'], // male born 2010-12-24 with +20 |
36
|
|
|
['108224/0016'], // female born 2010-12-24 with +20 |
37
|
|
|
['901224/0006'], // male born 1990-12-24 |
38
|
|
|
['906224/0011'], // female born 1990-12-24 |
39
|
|
|
['401224/001'], // male born 1940-12-24 |
40
|
|
|
['406224/002'], // female born 1940-12-24 |
41
|
|
|
]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testInvalidLength() |
45
|
|
|
{ |
46
|
|
|
$this->assertFalse( |
47
|
|
|
TINValid::checkTIN('cz', '01224/0006') |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testInvalidCharacter() |
52
|
|
|
{ |
53
|
|
|
$this->assertFalse( |
54
|
|
|
TINValid::checkTIN('cz', '90A224/0006') |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testInvalidMonth() |
59
|
|
|
{ |
60
|
|
|
$this->assertFalse( |
61
|
|
|
TINValid::checkTIN('cz', '901524/0006') |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// public function testPlus20InMonthInWrongYear() |
66
|
|
|
// { |
67
|
|
|
// $this->assertFalse( |
68
|
|
|
// TINValid::checkTIN('cz', '902124/0003') |
69
|
|
|
// ); |
70
|
|
|
// } |
71
|
|
|
|
72
|
|
|
// public function testPlus20InMonthInSeeminglyCorrectYearDifferentiatedByMissingModulo() |
73
|
|
|
// { |
74
|
|
|
// $this->assertFalse( |
75
|
|
|
// TINValid::checkTIN('cz', '052124/001') |
76
|
|
|
// ); |
77
|
|
|
// } |
78
|
|
|
|
79
|
|
|
public function testDayShouldNotBeZero() |
80
|
|
|
{ |
81
|
|
|
$this->assertFalse( |
82
|
|
|
TINValid::checkTIN('cz', '501200/001') |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testDayShouldNotBeGreaterThan31() |
87
|
|
|
{ |
88
|
|
|
$this->assertFalse( |
89
|
|
|
TINValid::checkTIN('cz', '500132/001') |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// public function testAfterYear53ModuloIsRequired() |
94
|
|
|
// { |
95
|
|
|
// $this->assertFalse( |
96
|
|
|
// TINValid::checkTIN('cz', '540101/001') |
97
|
|
|
// ); |
98
|
|
|
// } |
99
|
|
|
|
100
|
|
|
// public function testWithoutModuloSequenceShouldNotBeZero() |
101
|
|
|
// { |
102
|
|
|
// $this->assertFalse( |
103
|
|
|
// TINValid::checkTIN('cz', '500101/000') |
104
|
|
|
// ); |
105
|
|
|
// } |
106
|
|
|
|
107
|
|
|
// public function testIncorrectModulo() |
108
|
|
|
// { |
109
|
|
|
// $this->assertFalse( |
110
|
|
|
// TINValid::checkTIN('cz', '540101/0008') |
111
|
|
|
// ); |
112
|
|
|
// } |
113
|
|
|
|
114
|
|
|
// public function testIncorrectModuloIsCorrectIfItShouldBe10() |
115
|
|
|
// { |
116
|
|
|
// $this->assertFalse( |
117
|
|
|
// TINValid::checkTIN('cz', '540101/0110') |
118
|
|
|
// ); |
119
|
|
|
// } |
120
|
|
|
} |
121
|
|
|
|