1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MinepicTests\Helpers; |
6
|
|
|
|
7
|
|
|
use MinepicTests\TestCase; |
8
|
|
|
|
9
|
|
|
class UserDataValidatorTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function shouldValidateUsernameDataProvider(): array |
12
|
|
|
{ |
13
|
|
|
return [ |
14
|
|
|
['ZioPino'], |
15
|
|
|
['Elon_Musk'], |
16
|
|
|
['AVeryLongUsername'], |
17
|
|
|
]; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @test |
22
|
|
|
* @dataProvider shouldValidateUsernameDataProvider |
23
|
|
|
* |
24
|
|
|
* @param $value |
25
|
|
|
*/ |
26
|
|
|
public function shouldValidateUsername($value): void |
27
|
|
|
{ |
28
|
|
|
$this->assertTrue( |
29
|
|
|
\Minepic\Helpers\UserDataValidator::isValidUsername($value) |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function shouldNotValidateUsernameDataProvider(): array |
34
|
|
|
{ |
35
|
|
|
return [ |
36
|
|
|
['!LOL'], |
37
|
|
|
['EB&ACA'], |
38
|
|
|
['Invalid@Username'], |
39
|
|
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @test |
44
|
|
|
* @dataProvider shouldNotValidateUsernameDataProvider |
45
|
|
|
* |
46
|
|
|
* @param $value |
47
|
|
|
*/ |
48
|
|
|
public function shouldNotValidateUsername($value): void |
49
|
|
|
{ |
50
|
|
|
$this->assertFalse( |
51
|
|
|
\Minepic\Helpers\UserDataValidator::isValidUsername($value) |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function shouldValidateUuidDataProvider(): array |
56
|
|
|
{ |
57
|
|
|
return [ |
58
|
|
|
['6257a83ef36c4ba29115f4213869d5fb'], |
59
|
|
|
['45f50155c09f4fdcb5cee30af2ebd1f0'], |
60
|
|
|
['f498513ce8c84773be26ecfc7ed5185d'], |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @test |
66
|
|
|
* @dataProvider shouldValidateUuidDataProvider |
67
|
|
|
* |
68
|
|
|
* @param $value |
69
|
|
|
*/ |
70
|
|
|
public function shouldValidateUuid($value): void |
71
|
|
|
{ |
72
|
|
|
$this->assertTrue( |
73
|
|
|
\Minepic\Helpers\UserDataValidator::isValidUuid($value) |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function shouldNotValidateUuidDataProvider(): array |
78
|
|
|
{ |
79
|
|
|
return [ |
80
|
|
|
['____a83ef36c4ba29115f4213869d5fb'], |
81
|
|
|
['45f50155c09f4fdcb5cee30af2e!!!!'], |
82
|
|
|
['f498513🤬84773be26ecfc7ed5185d'], |
83
|
|
|
]; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @test |
88
|
|
|
* @dataProvider shouldNotValidateUuidDataProvider |
89
|
|
|
* |
90
|
|
|
* @param $value |
91
|
|
|
*/ |
92
|
|
|
public function shouldNotValidateUuid($value): void |
93
|
|
|
{ |
94
|
|
|
$this->assertFalse( |
95
|
|
|
\Minepic\Helpers\UserDataValidator::isValidUuid($value) |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function shouldValidateEmailDataProvider(): array |
100
|
|
|
{ |
101
|
|
|
return [ |
102
|
|
|
['[email protected]'], |
103
|
|
|
['[email protected]'], |
104
|
|
|
['[email protected]'], |
105
|
|
|
]; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @test |
110
|
|
|
* @dataProvider shouldValidateEmailDataProvider |
111
|
|
|
* |
112
|
|
|
* @param $value |
113
|
|
|
*/ |
114
|
|
|
public function shouldValidateEmail($value): void |
115
|
|
|
{ |
116
|
|
|
$this->assertTrue( |
117
|
|
|
\Minepic\Helpers\UserDataValidator::isValidEmail($value) |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function shouldNotValidateEmailDataProvider(): array |
122
|
|
|
{ |
123
|
|
|
return [ |
124
|
|
|
['@[email protected]'], |
125
|
|
|
['user.test+lole_xample.com'], |
126
|
|
|
['[email protected]@lol'], |
127
|
|
|
]; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @test |
132
|
|
|
* @dataProvider shouldNotValidateEmailDataProvider |
133
|
|
|
* |
134
|
|
|
* @param $value |
135
|
|
|
*/ |
136
|
|
|
public function shouldNotValidateEmail($value): void |
137
|
|
|
{ |
138
|
|
|
$this->assertFalse( |
139
|
|
|
\Minepic\Helpers\UserDataValidator::isValidEmail($value) |
140
|
|
|
); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|