44
55use MabeEnum \Enum ;
66use MabeEnumPHPStan \EnumDynamicReturnTypeExtension ;
7- use PHPStan \Reflection \Dummy \ DummyMethodReflection ;
7+ use PHPStan \Reflection \MethodReflection ;
88use PHPStan \Testing \PHPStanTestCase ;
99
1010class EnumDynamicReturnTypeExtensionTest extends PHPStanTestCase
@@ -24,41 +24,49 @@ public function testGetClass(): void
2424 $ this ->assertSame (Enum::class, $ this ->extension ->getClass ());
2525 }
2626
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+
2735 /** @dataProvider staticMethodsProvider */
2836 public function testIsStaticMethodSupportedShouldReturnTrue (string $ method ): void
2937 {
30- $ reflectionMethod = new DummyMethodReflection ($ method );
38+ $ reflectionMethod = $ this -> createMethodWithName ($ method );
3139 $ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
3240
33- $ reflectionMethod = new DummyMethodReflection (strtolower ($ method ));
41+ $ reflectionMethod = $ this -> createMethodWithName (strtolower ($ method ));
3442 $ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
3543
36- $ reflectionMethod = new DummyMethodReflection (strtoupper ($ method ));
44+ $ reflectionMethod = $ this -> createMethodWithName (strtoupper ($ method ));
3745 $ this ->assertTrue ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
3846 }
3947
4048 public function testIsStaticMethodSupportedShouldReturnFalse (): void
4149 {
42- $ reflectionMethod = new DummyMethodReflection ('fooBar ' );
50+ $ reflectionMethod = $ this -> createMethodWithName ('fooBar ' );
4351 $ this ->assertFalse ($ this ->extension ->isStaticMethodSupported ($ reflectionMethod ));
4452 }
4553
4654 /** @dataProvider objectMethodsProvider */
4755 public function testIsMethodSupportedShouldReturnTrue (string $ method ): void
4856 {
49- $ reflectionMethod = new DummyMethodReflection ($ method );
57+ $ reflectionMethod = $ this -> createMethodWithName ($ method );
5058 $ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
5159
52- $ reflectionMethod = new DummyMethodReflection (strtolower ($ method ));
60+ $ reflectionMethod = $ this -> createMethodWithName (strtolower ($ method ));
5361 $ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
5462
55- $ reflectionMethod = new DummyMethodReflection (strtoupper ($ method ));
63+ $ reflectionMethod = $ this -> createMethodWithName (strtoupper ($ method ));
5664 $ this ->assertTrue ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
5765 }
5866
5967 public function testIsMethodSupportedShouldReturnFalse (): void
6068 {
61- $ reflectionMethod = new DummyMethodReflection ('fooBar ' );
69+ $ reflectionMethod = $ this -> createMethodWithName ('fooBar ' );
6270 $ this ->assertFalse ($ this ->extension ->isMethodSupported ($ reflectionMethod ));
6371 }
6472
0 commit comments