Passed
Push — develop ( 3c29f3...131cab )
by Mathieu
01:35
created

ValidatorTest   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 137
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 73
dl 0
loc 137
rs 10
c 2
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidateEqualTo() 0 7 1
A testValidateLessThanOrEqual() 0 7 1
A testType() 0 16 1
A testValidateFalse() 0 10 1
A testValidateGreaterThanOrEqual() 0 7 1
A testBlank() 0 7 1
A testValidateLessThan() 0 7 1
A testValidateIdenticalTo() 0 11 1
A testNull() 0 13 1
A testValidateGreaterThan() 0 7 1
A testAlnum() 0 11 1
A testValidateTrue() 0 9 1
1
<?php
2
class ValidatorTest extends \PHPUnit\Framework\TestCase
3
{
4
    public function testValidateTrue()
5
    {
6
        $test = true;
7
8
        $validator = new \Suricate\Validator($test);
9
        $validator->true("Not true");
10
        $this->assertSame(0, count($validator->getErrors()));
11
        $this->assertTrue($validator->pass());
12
        $this->assertFalse($validator->fails());
13
14
    }
15
16
    public function testValidateFalse()
17
    {
18
        $test = true;
19
20
        $validator = new \Suricate\Validator($test);
21
        $validator->false("Not false");
22
        $this->assertSame(1, count($validator->getErrors()));
23
        $this->assertFalse($validator->pass());
24
        $this->assertTrue($validator->fails());
25
        $this->assertSame("Not false", $validator->getErrors()[0]);
26
    }
27
28
    public function testValidateEqualTo()
29
    {
30
        $test = true;
31
32
        $validator = new \Suricate\Validator($test);
33
        $validator->equalTo(true, "Not equal to 1");
0 ignored issues
show
Bug introduced by
The method equalTo() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        $validator->/** @scrutinizer ignore-call */ 
34
                    equalTo(true, "Not equal to 1");
Loading history...
34
        $this->assertTrue($validator->pass());
35
    }
36
37
    public function testValidateIdenticalTo()
38
    {
39
        $test = true;
40
41
        $validator = new \Suricate\Validator($test);
42
        $validator->identicalTo("1", "Not identical to 1");
0 ignored issues
show
Bug introduced by
The method identicalTo() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $validator->/** @scrutinizer ignore-call */ 
43
                    identicalTo("1", "Not identical to 1");
Loading history...
43
        $this->assertTrue($validator->fails());
44
45
        $validator = new \Suricate\Validator($test);
46
        $validator->identicalTo(1, "Not identical to 1");
47
        $this->assertTrue($validator->fails());
48
    }
49
50
    public function testValidateLessThan()
51
    {
52
        $test = 10;
53
54
        $validator = new \Suricate\Validator($test);
55
        $validator->lessThan(1, "Not less than 1");
0 ignored issues
show
Bug introduced by
The method lessThan() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $validator->/** @scrutinizer ignore-call */ 
56
                    lessThan(1, "Not less than 1");
Loading history...
56
        $this->assertTrue($validator->fails());
57
    }
58
59
    public function testValidateLessThanOrEqual()
60
    {
61
        $test = 10;
62
63
        $validator = new \Suricate\Validator($test);
64
        $validator->lessThanOrEqual(10, "Not <= than 10");
0 ignored issues
show
Bug introduced by
The method lessThanOrEqual() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        $validator->/** @scrutinizer ignore-call */ 
65
                    lessThanOrEqual(10, "Not <= than 10");
Loading history...
65
        $this->assertTrue($validator->pass());
66
    }
67
68
    public function testValidateGreaterThan()
69
    {
70
        $test = 10;
71
72
        $validator = new \Suricate\Validator($test);
73
        $validator->greaterThan(11, "Not greater than 11");
0 ignored issues
show
Bug introduced by
The method greaterThan() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

73
        $validator->/** @scrutinizer ignore-call */ 
74
                    greaterThan(11, "Not greater than 11");
Loading history...
74
        $this->assertTrue($validator->fails());
75
    }
76
77
    public function testValidateGreaterThanOrEqual()
78
    {
79
        $test = 10;
80
81
        $validator = new \Suricate\Validator($test);
82
        $validator->greaterThanOrEqual(10, "Not >= than 10");
0 ignored issues
show
Bug introduced by
The method greaterThanOrEqual() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

82
        $validator->/** @scrutinizer ignore-call */ 
83
                    greaterThanOrEqual(10, "Not >= than 10");
Loading history...
83
        $this->assertTrue($validator->pass());
84
    }
85
86
    public function testBlank()
87
    {
88
        $test = '';
89
90
        $validator = new \Suricate\Validator($test);
91
        $validator->blank("Not blank");
0 ignored issues
show
Bug introduced by
The method blank() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

91
        $validator->/** @scrutinizer ignore-call */ 
92
                    blank("Not blank");
Loading history...
92
        $this->assertTrue($validator->pass());
93
    }
94
95
    public function testNull()
96
    {
97
        $test = null;
98
99
        $validator = new \Suricate\Validator($test);
100
        $validator->null("Not null");
0 ignored issues
show
Bug introduced by
The method null() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

100
        $validator->/** @scrutinizer ignore-call */ 
101
                    null("Not null");
Loading history...
101
        $this->assertTrue($validator->pass());
102
103
        $test = 0;
104
105
        $validator = new \Suricate\Validator($test);
106
        $validator->null("Not null");
107
        $this->assertFalse($validator->pass());
108
    }
109
110
    public function testType()
111
    {
112
        $test = [1, 2, 3];
113
        $validator = new \Suricate\Validator($test);
114
        $validator->type('array', "Not an array");
0 ignored issues
show
Bug introduced by
The method type() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

114
        $validator->/** @scrutinizer ignore-call */ 
115
                    type('array', "Not an array");
Loading history...
115
        $this->assertTrue($validator->pass());
116
117
        $test = true;
118
        $validator = new \Suricate\Validator($test);
119
        $validator->type('bool', "Not a bool");
120
        $this->assertTrue($validator->pass());
121
122
        $test = 1;
123
        $validator = new \Suricate\Validator($test);
124
        $validator->type('bool', "Not a bool");
125
        $this->assertTrue($validator->fails());
126
    }
127
128
    public function testAlnum()
129
    {
130
        $test = '!aa';
131
        $validator = new \Suricate\Validator($test);
132
        $validator->alnum('Not alphanumeric');
0 ignored issues
show
Bug introduced by
The method alnum() does not exist on Suricate\Validator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

132
        $validator->/** @scrutinizer ignore-call */ 
133
                    alnum('Not alphanumeric');
Loading history...
133
        $this->assertTrue($validator->fails());
134
135
        $test = 'aa123z';
136
        $validator = new \Suricate\Validator($test);
137
        $validator->alnum('Not alphanumeric');
138
        $this->assertTrue($validator->pass());
139
    }
140
}