Skip to content

Commit a93213a

Browse files
committed
Add RequestStack and TranslatorInterface to base functional command test
1 parent 3d4e124 commit a93213a

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/ApiPlatform/State/Base/Wrapper/BaseResourceWrapperProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
* This file is part of the twelvepics-com/php-location-api project.
4+
* This file is part of the ixnode/php-api-version-bundle project.
55
*
66
* (c) Björn Hempel <https://www.hempel.li/>
77
*
@@ -288,7 +288,6 @@ protected function getRequestMethod(): string
288288
* @throws ArrayKeyNotFoundException
289289
* @throws CaseInvalidException
290290
* @throws CaseUnsupportedException
291-
* @throws ClassInvalidException
292291
* @throws TypeInvalidException
293292
*/
294293
protected function getResourceWrapper(BasePublicResource|array $baseResource, string $timeTaken): ResourceWrapper

src/ApiPlatform/State/Base/Wrapper/ResourceWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
* This file is part of the twelvepics-com/php-location-api project.
4+
* This file is part of the ixnode/php-api-version-bundle project.
55
*
66
* (c) Björn Hempel <https://www.hempel.li/>
77
*

tests/Functional/Command/Base/BaseFunctionalCommandTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
use Symfony\Component\Console\Command\Command;
3939
use Symfony\Component\Console\Tester\CommandTester;
4040
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
41+
use Symfony\Component\HttpFoundation\RequestStack;
42+
use Symfony\Contracts\Translation\TranslatorInterface;
4143
use 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

Comments
 (0)