Completed
Push — php70 ( 33bebb...e0e809 )
by Wim
02:48
created

testUseGroupDeclaration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 19
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 22
rs 9.2
1
<?php
2
/**
3
 * New use group declaration sniff tests
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * New use group declaration sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Wim Godden <[email protected]>
15
 */
16
class NewGroupUseDeclarationsSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * Test use group declaration
20
     *
21
     * @return void
22
     */
23
    public function testUseGroupDeclaration()
24
    {
25
        $file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '5.6');
26
        $this->assertNoViolation($file, 4);
27
        $this->assertNoViolation($file, 5);
28
        $this->assertNoViolation($file, 6);
29
        $this->assertNoViolation($file, 8);
30
        $this->assertNoViolation($file, 9);
31
        $this->assertNoViolation($file, 10);
32
        $this->assertError($file, 13, "Group use declarations are not allowed in PHP 5.6 or earlier");
33
        $this->assertError($file, 14, "Group use declarations are not allowed in PHP 5.6 or earlier");
34
35
        $file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '7.0');
36
        $this->assertNoViolation($file, 4);
37
        $this->assertNoViolation($file, 5);
38
        $this->assertNoViolation($file, 6);
39
        $this->assertNoViolation($file, 8);
40
        $this->assertNoViolation($file, 9);
41
        $this->assertNoViolation($file, 10);
42
        $this->assertNoViolation($file, 13);
43
        $this->assertNoViolation($file, 14);
44
    }
45
    
46
    /**
47
     * Test unserialize() options parameter
48
     *
49
     * @return void
50
     */
51
    public function testUnserializeOptions()
52
    {
53
        $file = $this->sniffFile('sniff-examples/new_function_parameter.php', '5.6');
54
        $this->assertError($file, 5, "The function unserialize does not have a parameter options in PHP version 5.6 or earlier");
55
    
56
        $file = $this->sniffFile('sniff-examples/new_function_parameter.php', '7.0');
57
        $this->assertNoViolation($file, 5);
58
    }
59
}
60