|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
| 5 | +use PHPStan\Reflection\ParametersAcceptorSelector; |
5 | 6 | use PHPStan\Testing\TestCase; |
| 7 | +use PHPStan\Type\VerbosityLevel; |
6 | 8 | use Timeweb\PHPStan\Reflection\EnumMethodReflection; |
7 | 9 | use Timeweb\PHPStan\Reflection\EnumMethodsClassReflectionExtension; |
8 | 10 |
|
@@ -69,4 +71,38 @@ public function testEnumMethodReflectionCanBeObtained() |
69 | 71 |
|
70 | 72 | $this->assertInstanceOf(EnumMethodReflection::class, $methodReflection); |
71 | 73 | } |
| 74 | + |
| 75 | + /** |
| 76 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::getName |
| 77 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::getDeclaringClass |
| 78 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::isStatic |
| 79 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::isPrivate |
| 80 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::isPublic |
| 81 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::getPrototype |
| 82 | + * @covers \Timeweb\PHPStan\Reflection\EnumMethodReflection::getVariants |
| 83 | + * @uses Timeweb\PHPStan\Reflection\EnumMethodReflection |
| 84 | + * @dataProvider enumFixtureProperties |
| 85 | + */ |
| 86 | + public function testEnumMethodProperties(string $propertyName) |
| 87 | + { |
| 88 | + $classReflection = $this->broker->getClass(EnumFixture::class); |
| 89 | + $methodReflection = $this->reflectionExtension->getMethod($classReflection, $propertyName); |
| 90 | + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); |
| 91 | + |
| 92 | + $this->assertSame($propertyName, $methodReflection->getName()); |
| 93 | + $this->assertSame($classReflection, $methodReflection->getDeclaringClass()); |
| 94 | + $this->assertTrue($methodReflection->isStatic()); |
| 95 | + $this->assertFalse($methodReflection->isPrivate()); |
| 96 | + $this->assertTrue($methodReflection->isPublic()); |
| 97 | + $this->assertSame(EnumFixture::class, $parametersAcceptor->getReturnType()->describe(VerbosityLevel::value())); |
| 98 | + } |
| 99 | + |
| 100 | + public function enumFixtureProperties(): array |
| 101 | + { |
| 102 | + return [ |
| 103 | + ['MEMBER'], |
| 104 | + ['PUBLIC_CONST'], |
| 105 | + ['PRIVATE_CONST'], |
| 106 | + ]; |
| 107 | + } |
72 | 108 | } |
0 commit comments