-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathValidationTest.php
More file actions
80 lines (74 loc) · 1.79 KB
/
ValidationTest.php
File metadata and controls
80 lines (74 loc) · 1.79 KB
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
<?php
namespace Rakit\Validation\Tests;
use Rakit\Validation\Validation;
use Rakit\Validation\Validator;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class ValidationTest extends TestCase
{
/**
* @param string $rules
* @param array $expectedResult
*
* @dataProvider parseRuleProvider
*/
public function testParseRule($rules, $expectedResult)
{
$class = new ReflectionClass(Validation::class);
$method = $class->getMethod('parseRule');
$method->setAccessible(true);
$validation = new Validation(new Validator(), [], []);
$result = $method->invokeArgs($validation, [$rules]);
$this->assertSame($expectedResult, $result);
}
/**
* @return array
*/
public function parseRuleProvider()
{
return [
[
'email',
[
'email',
[],
],
],
[
'min:6',
[
'min',
['6'],
],
],
[
'uploaded_file:0,500K,png,jpeg',
[
'uploaded_file',
['0', '500K', 'png', 'jpeg'],
],
],
[
'same:password',
[
'same',
['password'],
],
],
[
'regex:/^([a-zA-Z\,]*)$/',
[
'regex',
['/^([a-zA-Z\,]*)$/'],
],
],
[
"in:a,b\,c,d\,e",
[
'in',
['a','b,c','d,e']
]
]
];
}
}