IntegerValidationTest::itShouldCheckIfItIsOdd()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4286
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 9/20/14
5
 * Time: 12:03 PM
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Tests\NilPortugues\Validator\Validation\Integer;
12
13
use NilPortugues\Validator\Validation\Integer\IntegerValidation;
14
15
/**
16
 * Class IntegerValidationTest
17
 * @package Tests\NilPortugues\Validator\Validation\IntegerAttribute
18
 */
19
class IntegerValidationTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @test
23
     */
24
    public function itShouldCheckIfItIsFloat()
25
    {
26
        $this->assertTrue(IntegerValidation::isInteger(3));
27
        $this->assertFalse(IntegerValidation::isInteger(3.14));
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function itShouldCheckIfItIsNotZero()
34
    {
35
        $this->assertTrue(IntegerValidation::isNotZero(3));
36
        $this->assertFalse(IntegerValidation::isNotZero(0));
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function itShouldCheckIfItIsPositive()
43
    {
44
        $this->assertTrue(IntegerValidation::isPositive(3));
45
        $this->assertFalse(IntegerValidation::isPositive(-3));
46
        $this->assertFalse(IntegerValidation::isPositive(0));
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function itShouldCheckIfItIsPositiveOrZero()
53
    {
54
        $this->assertTrue(IntegerValidation::isPositiveOrZero(3));
55
        $this->assertTrue(IntegerValidation::isPositiveOrZero(0));
56
        $this->assertFalse(IntegerValidation::isPositiveOrZero(-3));
57
    }
58
59
    /**
60
     * @test
61
     */
62
    public function itShouldCheckIfItIsNegativeOrZero()
63
    {
64
        $this->assertTrue(IntegerValidation::isNegativeOrZero(-3));
65
        $this->assertTrue(IntegerValidation::isNegativeOrZero(0));
66
        $this->assertFalse(IntegerValidation::isNegativeOrZero(3));
67
    }
68
69
    /**
70
     * @test
71
     */
72
    public function itShouldCheckIfItIsNegative()
73
    {
74
        $this->assertTrue(IntegerValidation::isNegative(-3));
75
        $this->assertFalse(IntegerValidation::isNegative(3));
76
    }
77
78
    /**
79
     * @test
80
     */
81
    public function itShouldCheckIfItIsBetween()
82
    {
83
        $this->assertTrue(IntegerValidation::isBetween(3, 1, 5, false));
84
        $this->assertTrue(IntegerValidation::isBetween(3, 1, 3, true));
85
86
        $this->assertFalse(IntegerValidation::isBetween(13, 1, 5, false));
87
        $this->assertFalse(IntegerValidation::isBetween(13, 1, 3, true));
88
    }
89
90
    /**
91
     * @test
92
     */
93
    public function itShouldCheckStringIsBetweenException()
94
    {
95
        $this->setExpectedException('\InvalidArgumentException');
96
        IntegerValidation::isBetween(3, 12, 4, false);
97
    }
98
99
    /**
100
     * @test
101
     */
102
    public function itShouldCheckIfItIsOdd()
103
    {
104
        $this->assertTrue(IntegerValidation::isOdd(3));
105
        $this->assertFalse(IntegerValidation::isOdd(4));
106
    }
107
108
    /**
109
     * @test
110
     */
111
    public function itShouldCheckIfItIsEven()
112
    {
113
        $this->assertTrue(IntegerValidation::isEven(4));
114
        $this->assertFalse(IntegerValidation::isEven(3));
115
    }
116
117
    /**
118
     * @test
119
     */
120
    public function itShouldCheckIfItIsMultiple()
121
    {
122
        $this->assertTrue(IntegerValidation::isMultiple(6, 3));
123
        $this->assertFalse(IntegerValidation::isMultiple(13, 7));
124
    }
125
}
126