4
4
5
5
use MabeEnum \Enum ;
6
6
use MabeEnumPHPStan \EnumDynamicReturnTypeExtension ;
7
- use PHPStan \Reflection \Dummy \ DummyMethodReflection ;
7
+ use PHPStan \Reflection \MethodReflection ;
8
8
use PHPStan \Testing \PHPStanTestCase ;
9
9
10
10
class EnumDynamicReturnTypeExtensionTest extends PHPStanTestCase
@@ -24,41 +24,49 @@ public function testGetClass(): void
24
24
$ this ->assertSame (Enum::class, $ this ->extension ->getClass ());
25
25
}
26
26
27
+ private function createMethodWithName (string $ name ): MethodReflection
28
+ {
29
+ $ method = $ this ->createMock (MethodReflection::class);
30
+ $ method ->method ('getName ' )->willReturn ($ name );
31
+
32
+ return $ method ;
33
+ }
34
+
27
35
/** @dataProvider staticMethodsProvider */
28
36
public function testIsStaticMethodSupportedShouldReturnTrue (string $ method ): void
29
37
{
30
- $ reflectionMethod = new DummyMethodReflection ($ method );
38
+ $ reflectionMethod = $ this -> createMethodWithName ($ method );
31
39
$ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
32
40
33
- $ reflectionMethod = new DummyMethodReflection (strtolower ($ method ));
41
+ $ reflectionMethod = $ this -> createMethodWithName (strtolower ($ method ));
34
42
$ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
35
43
36
- $ reflectionMethod = new DummyMethodReflection (strtoupper ($ method ));
44
+ $ reflectionMethod = $ this -> createMethodWithName (strtoupper ($ method ));
37
45
$ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
38
46
}
39
47
40
48
public function testIsStaticMethodSupportedShouldReturnFalse (): void
41
49
{
42
- $ reflectionMethod = new DummyMethodReflection ('fooBar ' );
50
+ $ reflectionMethod = $ this -> createMethodWithName ('fooBar ' );
43
51
$ this ->assertFalse ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
44
52
}
45
53
46
54
/** @dataProvider objectMethodsProvider */
47
55
public function testIsMethodSupportedShouldReturnTrue (string $ method ): void
48
56
{
49
- $ reflectionMethod = new DummyMethodReflection ($ method );
57
+ $ reflectionMethod = $ this -> createMethodWithName ($ method );
50
58
$ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
51
59
52
- $ reflectionMethod = new DummyMethodReflection (strtolower ($ method ));
60
+ $ reflectionMethod = $ this -> createMethodWithName (strtolower ($ method ));
53
61
$ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
54
62
55
- $ reflectionMethod = new DummyMethodReflection (strtoupper ($ method ));
63
+ $ reflectionMethod = $ this -> createMethodWithName (strtoupper ($ method ));
56
64
$ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
57
65
}
58
66
59
67
public function testIsMethodSupportedShouldReturnFalse (): void
60
68
{
61
- $ reflectionMethod = new DummyMethodReflection ('fooBar ' );
69
+ $ reflectionMethod = $ this -> createMethodWithName ('fooBar ' );
62
70
$ this ->assertFalse ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
63
71
}
64
72
0 commit comments