This repository has been archived by the owner on May 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
IdNumValidatorTest.php
90 lines (79 loc) · 2.3 KB
/
IdNumValidatorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @link https://github.com/yiiviet/yii2-validator
* @copyright Copyright (c) 2018 Yii Viet
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
*/
namespace yiiviet\tests\unit\validator;
use yii\base\DynamicModel;
/**
* Lớp IdNumValidatorTest
*
* @author Vuong Minh <[email protected]>
* @since 1.0
*/
class IdNumValidatorTest extends TestCase
{
/**
* @dataProvider idNumValidProvider
*/
public function testValidIdNum($idOld, $idNew, $cId)
{
$model = DynamicModel::validateData([
'idOld' => $idOld,
'idNew' => $idNew,
'cId' => $cId
], [
[['idOld', 'idNew', 'cId'], 'idnumvn']
]);
$this->assertFalse($model->hasErrors());
}
/**
* @dataProvider idNumValidProvider
*/
public function testValidIdNumExceptCID($idOld, $idNew, $cId)
{
$model = DynamicModel::validateData([
'idOld' => $idOld,
'idNew' => $idNew,
'cId' => $cId
], [
[['idOld', 'idNew', 'cId'], 'idnumvn', 'onlyId' => true]
]);
$this->assertTrue($model->hasErrors());
}
/**
* @dataProvider idNumInvalidProvider
*/
public function testInValidIdNum($idOld, $idNew, $cId)
{
$model = DynamicModel::validateData([
'idOld' => $idOld,
'idNew' => $idNew,
'cId' => $cId
], [
[['idOld', 'idNew', 'cId'], 'idnumvn']
]);
$this->assertTrue($model->hasErrors());
}
public function idNumValidProvider()
{
return [
['293422825', '001089000098', '405071000030'],
['025478996', '036087000067', '526099003096'],
['017351686', '016509820190', '722099000144'],
['293422825', '079301000099', '836200003212'],
['293422825', '2934228250', '961302004651'],
];
}
public function idNumInvalidProvider()
{
return [
['79a7sd9a7', '331089000098a', '415071000030'],
['987845687', '836087000067e', '506099003096'],
['465879754', '216509820190f', '782099000144'],
['39979800e', '079301000099e', '816200003212'],
['554979964', '2934228250fe', '981302004651'],
];
}
}