44
55use PhpParser \BuilderFactory ;
66use PhpParser \Node \Expr \StaticCall ;
7- use PHPUnit \ Framework \ TestCase ;
7+ use PHPStan \ Testing \ PHPStanTestCase ;
88use SaschaEgerer \PhpstanTypo3 \Service \PrototypeServiceDefinitionChecker ;
99use SaschaEgerer \PhpstanTypo3 \Service \ServiceDefinition ;
1010use SaschaEgerer \PhpstanTypo3 \Tests \Unit \Fixtures \NonPrototypeClass ;
1111use SaschaEgerer \PhpstanTypo3 \Tests \Unit \Fixtures \PrototypeClass ;
12+ use SaschaEgerer \PhpstanTypo3 \Tests \Unit \Fixtures \PrototypeClassWithoutConstructor ;
1213
13- final class PrototypeServiceDefinitionCheckerTest extends TestCase
14+ final class PrototypeServiceDefinitionCheckerTest extends PHPStanTestCase
1415{
1516
1617 private PrototypeServiceDefinitionChecker $ subject ;
@@ -40,17 +41,22 @@ public static function provideNonPrototypes(): \Generator
4041 public static function providePrototypes (): \Generator
4142 {
4243 $ builderFactory = new BuilderFactory ();
43- $ prototypeClass = $ builderFactory ->classConstFetch (PrototypeClass::class, 'class ' );
44+ $ prototypeClass = $ builderFactory ->classConstFetch (self ::class, 'class ' );
45+ $ prototypeClassWithoutConstructor = $ builderFactory ->classConstFetch (PrototypeClassWithoutConstructor::class, 'class ' );
4446
4547 yield 'Service definition has no tags, no method calls and class has no required constructor arguments ' => [
4648 $ builderFactory ->staticCall ('Foo ' , 'foo ' , [$ prototypeClass ]),
4749 new ServiceDefinition ('foo ' , 'bar ' , false , false , null , false , false , false ),
4850 ];
51+ yield 'Service definition has no tags, no method calls and class has no constructor at all ' => [
52+ $ builderFactory ->staticCall ('Foo ' , 'foo ' , [$ prototypeClassWithoutConstructor ]),
53+ new ServiceDefinition ('foo ' , 'bar ' , false , false , null , false , false , false ),
54+ ];
4955 }
5056
5157 protected function setUp (): void
5258 {
53- $ this ->subject = new PrototypeServiceDefinitionChecker ( );
59+ $ this ->subject = self :: getContainer ()-> getByType (PrototypeServiceDefinitionChecker::class );
5460 }
5561
5662 /**
@@ -69,4 +75,11 @@ public function testIsPrototypeIsFalse(StaticCall $node, ServiceDefinition $serv
6975 self ::assertFalse ($ this ->subject ->isPrototype ($ serviceDefinition , $ node ));
7076 }
7177
78+ public static function getAdditionalConfigFiles (): array
79+ {
80+ return [
81+ __DIR__ . '/../../../extension.neon ' ,
82+ ];
83+ }
84+
7285}
0 commit comments