3838use Symfony \Component \Console \Command \Command ;
3939use Symfony \Component \Console \Tester \CommandTester ;
4040use Symfony \Component \DependencyInjection \ParameterBag \ParameterBagInterface ;
41+ use Symfony \Component \HttpFoundation \RequestStack ;
42+ use Symfony \Contracts \Translation \TranslatorInterface ;
4143use Twig \Environment ;
4244
4345/**
@@ -68,6 +70,10 @@ abstract class BaseFunctionalCommandTest extends WebTestCase
6870
6971 protected Environment $ twig ;
7072
73+ protected RequestStack $ request ;
74+
75+ protected TranslatorInterface $ translator ;
76+
7177 protected CommandHelper $ commandHelper ;
7278
7379 protected bool $ useKernel = false ;
@@ -80,6 +86,10 @@ abstract class BaseFunctionalCommandTest extends WebTestCase
8086
8187 protected bool $ useTwig = false ;
8288
89+ protected bool $ useRequestStack = false ;
90+
91+ protected bool $ useTranslator = false ;
92+
8393 protected bool $ loadFixtures = false ;
8494
8595 protected bool $ forceLoadFixtures = false ;
@@ -178,6 +188,7 @@ protected function setConfigUseTwig(): self
178188 *
179189 * @return void
180190 * @throws Exception
191+ * @SuppressWarnings(PHPMD.NPathComplexity)
181192 */
182193 protected function setUp (): void
183194 {
@@ -208,6 +219,14 @@ protected function setUp(): void
208219 if ($ this ->useTwig ) {
209220 $ this ->createService (Environment::class);
210221 }
222+
223+ if ($ this ->useRequestStack ) {
224+ $ this ->createService (RequestStack::class);
225+ }
226+
227+ if ($ this ->useTranslator ) {
228+ $ this ->createService (TranslatorInterface::class);
229+ }
211230 }
212231
213232 /**
@@ -230,6 +249,8 @@ protected function createService(string $serviceName): void
230249 $ service instanceof Environment => $ this ->twig = $ service ,
231250 $ service instanceof ParameterBagInterface => $ this ->parameterBag = $ service ,
232251 $ service instanceof Repository => $ this ->repository = $ service ,
252+ $ service instanceof RequestStack => $ this ->request = $ service ,
253+ $ service instanceof TranslatorInterface => $ this ->translator = $ service ,
233254 default => throw new ClassInvalidException ($ service ::class, [
234255 CommandHelper::class,
235256 Entity::class,
0 commit comments