Code Duplication    Length = 20-30 lines in 3 locations

Tests/Sniffs/PHP/ConstantArraysUsingDefineSniffTest.php 1 location

@@ 16-35 (lines=20) @@
13
 * @package PHPCompatibility
14
 * @author Wim Godden <[email protected]>
15
 */
16
class ConstantArraysUsingDefineSniffTest  extends BaseSniffTest
17
{
18
    /**
19
     * Verify that checking for a specific version works
20
     *
21
     * @return void
22
     */
23
    public function testConstantArraysUsingDefine()
24
    {
25
        $file = $this->sniffFile('sniff-examples/constant_arrays_using_define.php', '7.0');
26
        $this->assertNoViolation($file, 3);
27
        $this->assertNoViolation($file, 9);
28
        $this->assertNoViolation($file, 15);
29
        
30
        $file = $this->sniffFile('sniff-examples/constant_arrays_using_define.php', '5.6');
31
        $this->assertError($file, 3, "Constant arrays using define are not allowed in PHP 5.6 or earlier");
32
        $this->assertError($file, 9, "Constant arrays using define are not allowed in PHP 5.6 or earlier");
33
        $this->assertNoViolation($file, 15);
34
    }
35
}
36

Tests/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniffTest.php 1 location

@@ 16-35 (lines=20) @@
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class ForbiddenSwitchWithMultipleDefaultBlocksSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * testSettingTestVersion
20
     *
21
     * @return void
22
     */
23
    public function testSettingTestVersion()
24
    {
25
        $file = $this->sniffFile('sniff-examples/forbidden_switch_with_multiple_default_blocks.php', '5.6');
26
        $this->assertNoViolation($file, 3);
27
        $this->assertNoViolation($file, 14);
28
        $this->assertNoViolation($file, 23);
29
        
30
        $file = $this->sniffFile('sniff-examples/forbidden_switch_with_multiple_default_blocks.php', '7.0');
31
        $this->assertError($file, 3, 'Switch statements can not have multiple default blocks since PHP 7.0');
32
        $this->assertNoViolation($file, 14);
33
        $this->assertNoViolation($file, 23);
34
    }
35
}
36
37

Tests/Sniffs/PHP/RemovedFunctionParameterSniffTest.php 1 location

@@ 16-45 (lines=30) @@
13
 * @package PHPCompatibility
14
 * @author Wim Godden <[email protected]>
15
 */
16
class RemovedFunctionParameterSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * Test mktime() is_dst parameter
20
     *
21
     * @return void
22
     */
23
    public function testMktimeIsdst()
24
    {
25
        $file = $this->sniffFile('sniff-examples/removed_function_parameter.php', '5.0');
26
        $this->assertNoViolation($file, 3);
27
        
28
        $file = $this->sniffFile('sniff-examples/removed_function_parameter.php', '7.0');
29
        $this->assertError($file, 3, "The function mktime does not have a parameter is_dst in PHP version 7.0 or later");
30
    }
31
    
32
    /**
33
     * Test gmmktime() is_dst parameter
34
     *
35
     * @return void
36
     */
37
    public function testGmmktimeIsdst()
38
    {
39
        $file = $this->sniffFile('sniff-examples/removed_function_parameter.php', '5.6');
40
        $this->assertNoViolation($file, 5);
41
    
42
        $file = $this->sniffFile('sniff-examples/removed_function_parameter.php', '7.0');
43
        $this->assertError($file, 5, "The function gmmktime does not have a parameter is_dst in PHP version 7.0 or later");
44
    }
45
}
46