|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace test\PhpStaticAnalysis\PsalmPlugin; |
| 4 | + |
| 5 | +class DeprecatedAttributeTest extends BaseAttributeTestCase |
| 6 | +{ |
| 7 | + public function testClassDeprecatedAttribute(): void |
| 8 | + { |
| 9 | + $errors = $this->analyzeTestFile( '/data/Deprecated/ClassDeprecatedAttribute.php'); |
| 10 | + $expectedErrors = [ |
| 11 | + 'test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated\ClassDeprecatedAttribute is marked deprecated' => 12, |
| 12 | + ]; |
| 13 | + |
| 14 | + $this->checkExpectedErrors($errors, $expectedErrors); |
| 15 | + } |
| 16 | + |
| 17 | + public function testTraitDeprecatedAttribute(): void |
| 18 | + { |
| 19 | + $errors = $this->analyzeTestFile( '/data/Deprecated/TraitDeprecatedAttribute.php'); |
| 20 | + $this->assertCount(0, $errors); |
| 21 | + } |
| 22 | + |
| 23 | + public function testInterfaceDeprecatedAttribute(): void |
| 24 | + { |
| 25 | + $errors = $this->analyzeTestFile('/data/Deprecated/InterfaceDeprecatedAttribute.php'); |
| 26 | + $this->assertCount(0, $errors); |
| 27 | + } |
| 28 | + |
| 29 | + public function testMethodDeprecatedAttribute(): void |
| 30 | + { |
| 31 | + $errors = $this->analyzeTestFile('/data/Deprecated/MethodDeprecatedAttribute.php'); |
| 32 | + $expectedErrors = [ |
| 33 | + 'The method test\PhpStaticAnalysis\PsalmPlugin\data\Deprecated\MethodDeprecatedAttribute::returnDeprecated has been marked as deprecated' => 31, |
| 34 | + ]; |
| 35 | + |
| 36 | + $this->checkExpectedErrors($errors, $expectedErrors); |
| 37 | + } |
| 38 | + |
| 39 | + public function testFunctionDeprecatedAttribute(): void |
| 40 | + { |
| 41 | + $errors = $this->analyzeTestFile('/data/Deprecated/FunctionDeprecatedAttribute.php'); |
| 42 | + $this->assertCount(0, $errors); |
| 43 | + } |
| 44 | + |
| 45 | + public function testProperyDeprecatedAttribute(): void |
| 46 | + { |
| 47 | + $errors = $this->analyzeTestFile('/data/Deprecated/PropertyDeprecatedAttribute.php'); |
| 48 | + $this->assertCount(0, $errors); |
| 49 | + } |
| 50 | + |
| 51 | + public function testInvalidMethodDeprecatedAttribute(): void |
| 52 | + { |
| 53 | + $errors = $this->analyzeTestFile('/data/Deprecated/InvalidMethodDeprecatedAttribute.php'); |
| 54 | + |
| 55 | + $expectedErrors = [ |
| 56 | + 'Attribute Deprecated cannot be used on a function/method parameter' => 12, |
| 57 | + 'Attribute Deprecated is not repeatable' => 19, |
| 58 | + ]; |
| 59 | + |
| 60 | + $this->checkExpectedErrors($errors, $expectedErrors); |
| 61 | + } |
| 62 | +} |
0 commit comments