Completed
Pull Request — master (#126)
by Ryan
02:50
created

NewUseDeclarationsSniffTest::testUseDeclaration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 17
rs 9.4285
1
<?php
2
/**
3
 * New use group declaration sniff tests
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * New use declaration sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Ryan Neufeld <[email protected]>
15
 */
16
class NewUseDeclarationsSniffTest extends BaseSniffTest
17
{
18
    /**
19
     * Test use group declaration
20
     *
21
     * @return void
22
     */
23
    public function testUseDeclaration()
24
    {
25
        if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) {
26
            $file = $this->sniffFile('sniff-examples/new_use_declarations.php', '5.5');
27
            $this->assertError($file, 4, "`use const` declarations are not allowed in PHP 5.5 or earlier");
28
            $this->assertError($file, 5, "`use const` declarations are not allowed in PHP 5.5 or earlier");
29
30
            $this->assertError($file, 7, "`use function` declarations are not allowed in PHP 5.5 or earlier");
31
            $this->assertError($file, 8, "`use function` declarations are not allowed in PHP 5.5 or earlier");
32
33
            $file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '5.6');
34
            $this->assertNoViolation($file, 4);
35
            $this->assertNoViolation($file, 5);
36
            $this->assertNoViolation($file, 7);
37
            $this->assertNoViolation($file, 8);
38
        }
39
    }
40
}