Completed
Branch master (d39ff3)
by Pierre-Henry
32:32
created

ValidateTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 50
rs 10
wmc 5
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testValidHexCode() 0 4 1
A testInvalidHexCode() 0 4 1
A validHexCodesProvider() 0 8 1
A invalidHexCodesProvider() 0 8 1
1
<?php
2
/**
3
 * @author           Pierre-Henry Soria <[email protected]>
4
 * @copyright        (c) 2018, Pierre-Henry Soria. All Rights Reserved.
5
 * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
6
 * @package          PH7 / Test / Unit / Framework / Security / Validate
7
 */
8
9
namespace PH7\Test\Unit\Framework\Security\Validate;
10
11
use PH7\Framework\Security\Validate\Validate;
12
use PHPUnit_Framework_TestCase;
13
14
class ValidateTest extends PHPUnit_Framework_TestCase
15
{
16
    /** @var Validate */
17
    private $oValidate;
18
19
    protected function setUp()
20
    {
21
        $this->oValidate = new Validate();
22
    }
23
24
    /**
25
     * @dataProvider validHexCodesProvider
26
     */
27
    public function testValidHexCode($sHexCode)
28
    {
29
        $this->assertTrue($this->oValidate->hex($sHexCode));
30
    }
31
32
    /**
33
     * @dataProvider invalidHexCodesProvider
34
     */
35
    public function testInvalidHexCode($sHexCode)
36
    {
37
        $this->assertFalse($this->oValidate->hex($sHexCode));
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function validHexCodesProvider()
44
    {
45
        return [
46
            ['#eee'],
47
            ['#EEE'],
48
            ['#eeeeee']
49
        ];
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function invalidHexCodesProvider()
56
    {
57
        return [
58
            ['eee'],
59
            ['#fffffff'],
60
            ['#cc']
61
        ];
62
    }
63
}
64