Completed
Pull Request — master (#149)
by Juliette
02:28
created

RemovedHashAlgorithmsSniffTest::testHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Removed hash algorithms sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Removed hash algorithms sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class RemovedHashAlgorithmsSniffTest extends BaseSniffTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    /**
19
     * Sniffed file
20
     *
21
     * @var PHP_CodeSniffer_File
22
     */
23
    protected $_sniffFile;
24
25
    /**
26
     * setUp
27
     *
28
     * @return void
29
     */
30
    public function setUp()
31
    {
32
        parent::setUp();
33
34
        $this->_sniffFile = $this->sniffFile('sniff-examples/removed_hash_algorithms.php');
35
    }
36
37
    /**
38
     * testRemovedHashAlgorithms
39
     *
40
     * @dataProvider dataRemovedHashAlgorithms
41
     *
42
     * @param int $line Line number on which an error should occur.
43
     *
44
     * @return void
45
     */
46
    public function testRemovedHashAlgorithms($line)
47
    {
48
        $this->assertError($this->_sniffFile, $line, 'The Salsa10 and Salsa20 hash algorithms have been removed since PHP 5.4');
49
    }
50
51
    /**
52
     * dataRemovedHashAlgorithms
53
     *
54
     * @see testRemovedHashAlgorithms()
55
     *
56
     * @return array
57
     */
58 View Code Duplication
    public function dataRemovedHashAlgorithms()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        return array(
61
            array(4),
62
            array(5),
63
            array(6),
64
            array(7),
65
            array(9),
66
            array(11),
67
            array(13),
68
            array(15),
69
            array(16),
70
        );
71
    }
72
73
74
    /**
75
     * testOkHashAlgorithm
76
     *
77
     * @return void
78
     */
79
    public function testOkHashAlgorithm()
80
    {
81
        $this->assertNoViolation($this->_sniffFile, 3);
82
    }
83
84
    /**
85
     * testIgnoreSecondParameter
86
     *
87
     * @return void
88
     */
89
    public function testIgnoreSecondParameter()
90
    {
91
        $this->assertNoViolation($this->_sniffFile, 17);
92
    }
93
94
    /**
95
     * testIgnoreNonFunctionCall
96
     *
97
     * @return void
98
     */
99
    public function testIgnoreNonFunctionCall()
100
    {
101
        $this->assertNoViolation($this->_sniffFile, 18);
102
    }
103
104
}
105