|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace test\PhpStaticAnalysis\PHPStanExtension; |
| 4 | + |
| 5 | +class InternalAttributeTest extends BaseAttributeTestCase |
| 6 | +{ |
| 7 | + public function testClassInternalAttribute(): void |
| 8 | + { |
| 9 | + $errors = $this->analyse(__DIR__ . '/data/Internal/ClassInternalAttribute.php'); |
| 10 | + $this->assertCount(0, $errors); |
| 11 | + } |
| 12 | + |
| 13 | + public function testTraitInternalAttribute(): void |
| 14 | + { |
| 15 | + $errors = $this->analyse(__DIR__ . '/data/Internal/TraitInternalAttribute.php'); |
| 16 | + $this->assertCount(0, $errors); |
| 17 | + } |
| 18 | + |
| 19 | + public function testInterfaceInternalAttribute(): void |
| 20 | + { |
| 21 | + $errors = $this->analyse(__DIR__ . '/data/Internal/InterfaceInternalAttribute.php'); |
| 22 | + $this->assertCount(0, $errors); |
| 23 | + } |
| 24 | + |
| 25 | + public function testMethodInternalAttribute(): void |
| 26 | + { |
| 27 | + $errors = $this->analyse(__DIR__ . '/data/Internal/MethodInternalAttribute.php'); |
| 28 | + $this->assertCount(0, $errors); |
| 29 | + } |
| 30 | + |
| 31 | + public function testFunctionInternalAttribute(): void |
| 32 | + { |
| 33 | + $errors = $this->analyse(__DIR__ . '/data/Internal/FunctionInternalAttribute.php'); |
| 34 | + $this->assertCount(0, $errors); |
| 35 | + } |
| 36 | + |
| 37 | + public function testProperyInternalAttribute(): void |
| 38 | + { |
| 39 | + $errors = $this->analyse(__DIR__ . '/data/Internal/PropertyInternalAttribute.php'); |
| 40 | + $this->assertCount(0, $errors); |
| 41 | + } |
| 42 | + |
| 43 | + public function testInvalidMethodInternalAttribute(): void |
| 44 | + { |
| 45 | + $errors = $this->analyse(__DIR__ . '/data/Internal/InvalidMethodInternalAttribute.php'); |
| 46 | + $expectedErrors = [ |
| 47 | + 'Parameter #1 $namespace of attribute class PhpStaticAnalysis\Attributes\Internal constructor expects string|null, int given.' => 9, |
| 48 | + 'Attribute class PhpStaticAnalysis\Attributes\Internal does not have the parameter target.' => 15, |
| 49 | + 'Attribute class PhpStaticAnalysis\Attributes\Internal is not repeatable but is already present above the method.' => 22, |
| 50 | + ]; |
| 51 | + |
| 52 | + $this->checkExpectedErrors($errors, $expectedErrors); |
| 53 | + } |
| 54 | +} |
0 commit comments