| 1 | <?php |
||
| 15 | class DeprecatedPHP4StyleConstructorsSniffTest extends BaseSniffTest |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Test PHP4 style constructors. |
||
| 19 | * |
||
| 20 | * @group deprecatedPHP4Constructors |
||
| 21 | * |
||
| 22 | * @return void |
||
| 23 | */ |
||
| 24 | public function testIsDeprecated() |
||
| 25 | { |
||
| 26 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '5.6'); |
||
| 27 | $this->assertNoViolation($file, 3); |
||
| 28 | |||
| 29 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '7.0'); |
||
| 30 | $this->assertError($file, 3, 'Deprecated PHP4 style constructor are not supported since PHP7'); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Test valid methods with the same name as the class. |
||
| 35 | * |
||
| 36 | * @group deprecatedPHP4Constructors |
||
| 37 | * |
||
| 38 | * @return void |
||
| 39 | */ |
||
| 40 | public function testValidMethods() |
||
| 41 | { |
||
| 42 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '7.0'); |
||
| 43 | $this->assertNoViolation($file, 9); |
||
| 44 | |||
| 45 | if (version_compare(phpversion(), '5.3', '>=')) { |
||
| 46 | // Will only be no violation if namespaces are recognized. |
||
| 47 | $this->assertNoViolation($file, 20); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 |