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/NewFunctionParameterSniffTest.php 1 location

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