@@ -62,20 +62,49 @@ abstract class BaseFunctionalCommandTest extends WebTestCase
6262
6363 protected CommandTester $ commandTester ;
6464
65+
6566 protected ParameterBagInterface $ parameterBag ;
6667
68+ /** @var class-string<ParameterBagInterface> $parameterBagClass */
69+ protected string $ parameterBagClass = ParameterBagInterface::class;
70+
71+
6772 protected Entity $ entity ;
6873
74+ /** @var class-string<Entity> $entityClass */
75+ protected string $ entityClass = Entity::class;
76+
77+
6978 protected Repository $ repository ;
7079
80+ /** @var class-string<Repository> $repositoryClass */
81+ protected string $ repositoryClass = Repository::class;
82+
83+
7184 protected Environment $ twig ;
7285
86+ /** @var class-string<Environment> $twigClass */
87+ protected string $ twigClass = Environment::class;
88+
89+
7390 protected RequestStack $ request ;
7491
92+ /** @var class-string<RequestStack> $requestClass */
93+ protected string $ requestClass = RequestStack::class;
94+
95+
7596 protected TranslatorInterface $ translator ;
7697
98+ /** @var class-string<TranslatorInterface> $translatorClass */
99+ protected string $ translatorClass = TranslatorInterface::class;
100+
101+
77102 protected CommandHelper $ commandHelper ;
78103
104+ /** @var class-string<CommandHelper> $commandHelperClass */
105+ protected string $ commandHelperClass = CommandHelper::class;
106+
107+
79108 protected bool $ useKernel = false ;
80109
81110 protected bool $ useCommand = false ;
@@ -232,32 +261,28 @@ protected function setUp(): void
232261 }
233262
234263 if ($ this ->useParameterBag ) {
235- $ this ->createService (ParameterBagInterface::class );
264+ $ this ->createService ($ this -> getServiceParameterBagClass () );
236265 }
237266
238267 if ($ this ->useDb ) {
239- $ this ->createService (Entity::class );
240- $ this ->createService (Repository::class );
268+ $ this ->createService ($ this -> getServiceEntityClass () );
269+ $ this ->createService ($ this -> getServiceRepositoryClass () );
241270 }
242271
243272 if ($ this ->useTwig ) {
244- $ this ->createService (Environment::class);
245- }
246-
247- if ($ this ->useRepository ) {
248- $ this ->createService (Repository::class);
273+ $ this ->createService ($ this ->getServiceEnvironmentClass ());
249274 }
250275
251276 if ($ this ->useRequestStack ) {
252- $ this ->createService (RequestStack::class );
277+ $ this ->createService ($ this -> getServiceRequestStackClass () );
253278 }
254279
255280 if ($ this ->useTranslator ) {
256- $ this ->createService (TranslatorInterface::class );
281+ $ this ->createService ($ this -> getServiceTranslatorClass () );
257282 }
258283
259284 if ($ this ->loadFixtures ) {
260- $ this ->createService (CommandHelper::class );
285+ $ this ->createService ($ this -> getServiceCommandHelperClass () );
261286 $ this ->loadFixtures ();
262287 }
263288
@@ -298,6 +323,138 @@ protected function createService(string $serviceName): void
298323 };
299324 }
300325
326+ /**
327+ * @return class-string<ParameterBagInterface>
328+ */
329+ public function getServiceParameterBagClass (): string
330+ {
331+ return $ this ->parameterBagClass ;
332+ }
333+
334+ /**
335+ * @param class-string<ParameterBagInterface> $parameterBagClass
336+ * @return self
337+ */
338+ public function setServiceParameterBagClass (string $ parameterBagClass ): self
339+ {
340+ $ this ->parameterBagClass = $ parameterBagClass ;
341+
342+ return $ this ;
343+ }
344+
345+ /**
346+ * @return class-string<Entity>
347+ */
348+ public function getServiceEntityClass (): string
349+ {
350+ return $ this ->entityClass ;
351+ }
352+
353+ /**
354+ * @param class-string<Entity> $entityClass
355+ * @return self
356+ */
357+ public function setServiceEntityClass (string $ entityClass ): self
358+ {
359+ $ this ->entityClass = $ entityClass ;
360+
361+ return $ this ;
362+ }
363+
364+ /**
365+ * @return class-string<Repository>
366+ */
367+ public function getServiceRepositoryClass (): string
368+ {
369+ return $ this ->repositoryClass ;
370+ }
371+
372+ /**
373+ * @param class-string<Repository> $repositoryClass
374+ * @return self
375+ */
376+ public function setServiceRepositoryClass (string $ repositoryClass ): self
377+ {
378+ $ this ->repositoryClass = $ repositoryClass ;
379+
380+ return $ this ;
381+ }
382+
383+ /**
384+ * @return class-string<Environment>
385+ */
386+ public function getServiceEnvironmentClass (): string
387+ {
388+ return $ this ->twigClass ;
389+ }
390+
391+ /**
392+ * @param class-string<Environment> $twigClass
393+ * @return self
394+ */
395+ public function setServiceEnvironmentClass (string $ twigClass ): self
396+ {
397+ $ this ->twigClass = $ twigClass ;
398+
399+ return $ this ;
400+ }
401+
402+ /**
403+ * @return class-string<RequestStack>
404+ */
405+ public function getServiceRequestStackClass (): string
406+ {
407+ return $ this ->requestClass ;
408+ }
409+
410+ /**
411+ * @param class-string<RequestStack> $requestClass
412+ * @return self
413+ */
414+ public function setServiceRequestClass (string $ requestClass ): self
415+ {
416+ $ this ->requestClass = $ requestClass ;
417+
418+ return $ this ;
419+ }
420+
421+ /**
422+ * @return class-string<TranslatorInterface>
423+ */
424+ public function getServiceTranslatorClass (): string
425+ {
426+ return $ this ->translatorClass ;
427+ }
428+
429+ /**
430+ * @param class-string<TranslatorInterface> $translatorClass
431+ * @return self
432+ */
433+ public function setServiceTranslatorClass (string $ translatorClass ): self
434+ {
435+ $ this ->translatorClass = $ translatorClass ;
436+
437+ return $ this ;
438+ }
439+
440+ /**
441+ * @return class-string<CommandHelper>
442+ */
443+ public function getServiceCommandHelperClass (): string
444+ {
445+ return $ this ->commandHelperClass ;
446+ }
447+
448+ /**
449+ * @param class-string<CommandHelper> $commandHelperClass
450+ * @return self
451+ */
452+ public function setServiceCommandHelperClass (string $ commandHelperClass ): self
453+ {
454+ $ this ->commandHelperClass = $ commandHelperClass ;
455+ return $ this ;
456+ }
457+
301458 /**
302459 * Creates the command.
303460 *
0 commit comments