Passed
Push — dev ( 5c4da4...f4770d )
by Mattia
05:20
created

UserDataValidatorTest::shouldValidateEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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