| @@ 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 | ||
| @@ 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 | ||