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
|
|
|
if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) { |
26
|
|
|
$file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '5.6'); |
27
|
|
|
$this->assertNoViolation($file, 4); |
28
|
|
|
$this->assertNoViolation($file, 5); |
29
|
|
|
$this->assertNoViolation($file, 6); |
30
|
|
|
$this->assertNoViolation($file, 8); |
31
|
|
|
$this->assertNoViolation($file, 9); |
32
|
|
|
$this->assertNoViolation($file, 10); |
33
|
|
|
$this->assertError($file, 13, "Group use declarations are not allowed in PHP 5.6 or earlier"); |
34
|
|
|
$this->assertError($file, 14, "Group use declarations are not allowed in PHP 5.6 or earlier"); |
35
|
|
|
|
36
|
|
|
$file = $this->sniffFile('sniff-examples/new_group_use_declarations.php', '7.0'); |
37
|
|
|
$this->assertNoViolation($file, 4); |
38
|
|
|
$this->assertNoViolation($file, 5); |
39
|
|
|
$this->assertNoViolation($file, 6); |
40
|
|
|
$this->assertNoViolation($file, 8); |
41
|
|
|
$this->assertNoViolation($file, 9); |
42
|
|
|
$this->assertNoViolation($file, 10); |
43
|
|
|
$this->assertNoViolation($file, 13); |
44
|
|
|
$this->assertNoViolation($file, 14); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |