Skip to content

Commit d60e0ba

Browse files
authored
Merge pull request #2280 from xabbuh/bump-phpunit-version
bump PHPUnit version
2 parents 61ea953 + 4f4779c commit d60e0ba

31 files changed

+171
-174
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
coverage: yes
3838
- php-version: 8.0
3939
composer-flags: "--ignore-platform-reqs"
40+
symfony-deprecations: "max[self]=0"
4041

4142
steps:
4243
- name: "Checkout"
@@ -68,7 +69,9 @@ jobs:
6869
- name: "Install dependencies with composer"
6970
env:
7071
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
71-
run: "composer update --no-interaction --no-progress ${{ matrix.composer-flags }}"
72+
run: |
73+
composer global require --no-progress --no-scripts --no-plugins symfony/flex
74+
composer update --no-interaction --no-progress ${{ matrix.composer-flags }}
7275
7376
- name: "Run PHPUnit"
7477
if: "${{ matrix.coverage != '' }}"
@@ -78,5 +81,7 @@ jobs:
7881
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
7982
8083
- name: "Run PHPUnit"
84+
env:
85+
SYMFONY_DEPRECATIONS_HELPER: "${{ matrix.symfony-deprecations }}"
8186
if: "${{ matrix.coverage == '' }}"
8287
run: "./phpunit"

.travis.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

Negotiation/FormatNegotiator.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
use Symfony\Component\HttpFoundation\RequestStack;
2020

2121
/**
22-
* @author Ener-Getick <[email protected]>
23-
*
24-
* @final since 2.8
22+
* @internal
2523
*/
26-
class FormatNegotiator extends BaseNegotiator
24+
class BaseFormatNegotiator extends BaseNegotiator
2725
{
2826
private $map = [];
2927
private $requestStack;
@@ -40,7 +38,10 @@ public function add(RequestMatcherInterface $requestMatcher, array $options = []
4038
$this->map[] = [$requestMatcher, $options];
4139
}
4240

43-
public function getBest($header, array $priorities = [])
41+
/**
42+
* @internal
43+
*/
44+
protected function doGetBest($header, array $priorities = [])
4445
{
4546
$request = $this->getRequest();
4647
$header = $header ?: $request->headers->get('Accept');
@@ -153,3 +154,31 @@ private function getRequest(): Request
153154
return $request;
154155
}
155156
}
157+
158+
if (method_exists(BaseNegotiator::class, 'getOrderedElements')) {
159+
/**
160+
* @author Guilhem Niot <[email protected]>
161+
*
162+
* @final since 2.8
163+
*/
164+
class FormatNegotiator extends BaseFormatNegotiator
165+
{
166+
public function getBest($header, array $priorities = [], $strict = false)
167+
{
168+
return $this->doGetBest($header, $priorities);
169+
}
170+
}
171+
} else {
172+
/**
173+
* @author Guilhem Niot <[email protected]>
174+
*
175+
* @final since 2.8
176+
*/
177+
class FormatNegotiator extends BaseFormatNegotiator
178+
{
179+
public function getBest($header, array $priorities = [])
180+
{
181+
return $this->doGetBest($header, $priorities);
182+
}
183+
}
184+
}

Routing/Loader/ClassUtils.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public static function findClassInFile(string $file): ?string
2323
$class = false;
2424
$namespace = false;
2525
$tokens = token_get_all(file_get_contents($file));
26+
27+
if (defined('T_NAME_QUALIFIED')) {
28+
$namespaceToken = T_NAME_QUALIFIED;
29+
} else {
30+
$namespaceToken = T_STRING;
31+
}
32+
2633
for ($i = 0, $count = count($tokens); $i < $count; ++$i) {
2734
$token = $tokens[$i];
2835

@@ -34,12 +41,12 @@ public static function findClassInFile(string $file): ?string
3441
return $namespace.'\\'.$token[1];
3542
}
3643

37-
if (true === $namespace && T_STRING === $token[0]) {
44+
if (true === $namespace && $namespaceToken === $token[0]) {
3845
$namespace = '';
3946
do {
4047
$namespace .= $token[1];
4148
$token = $tokens[++$i];
42-
} while ($i < $count && is_array($token) && in_array($token[0], [T_NS_SEPARATOR, T_STRING]));
49+
} while ($i < $count && is_array($token) && in_array($token[0], [T_NS_SEPARATOR, $namespaceToken]));
4350
}
4451

4552
if (T_CLASS === $token[0]) {

Tests/Decoder/JsonToFormDecoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function testDecodeWithRemovingFalseData()
3737
$decoder = new JsonToFormDecoder();
3838
$decoded = $decoder->decode(json_encode($data));
3939

40-
$this->assertInternalType('array', $decoded);
41-
$this->assertInternalType('array', $decoded['arrayKey']);
40+
$this->assertIsArray($decoded);
41+
$this->assertIsArray($decoded['arrayKey']);
4242
$this->assertNull($decoded['arrayKey']['falseKey']);
4343
$this->assertEquals('foo', $decoded['arrayKey']['stringKey']);
4444
$this->assertNull($decoded['falseKey']);

Tests/DependencyInjection/Compiler/ConfigurationCheckPassTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
*/
2323
class ConfigurationCheckPassTest extends TestCase
2424
{
25-
/**
26-
* @expectedException \RuntimeException
27-
* @expectedExceptionMessage You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter
28-
*/
2925
public function testShouldThrowRuntimeExceptionWhenBodyConverterIsEnabledButParamConvertersAreNotEnabled()
3026
{
27+
$this->expectException(\RuntimeException::class);
28+
$this->expectExceptionMessage('You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter');
29+
3130
$container = new ContainerBuilder();
3231

3332
$container->register('fos_rest.converter.request_body');
@@ -36,12 +35,11 @@ public function testShouldThrowRuntimeExceptionWhenBodyConverterIsEnabledButPara
3635
$compiler->process($container);
3736
}
3837

39-
/**
40-
* @expectedException \RuntimeException
41-
* @expectedExceptionMessage SensioFrameworkExtraBundle view annotations
42-
*/
4338
public function testExceptionWhenViewAnnotationsAreNotEnabled()
4439
{
40+
$this->expectException(\RuntimeException::class);
41+
$this->expectExceptionMessage('SensioFrameworkExtraBundle view annotations');
42+
4543
$container = new ContainerBuilder();
4644

4745
$container->register('fos_rest.view_response_listener');

Tests/DependencyInjection/Compiler/SerializerConfigurationPassTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SerializerConfigurationPassTest extends TestCase
2828
*/
2929
private $container;
3030

31-
protected function setUp()
31+
protected function setUp(): void
3232
{
3333
$this->container = new ContainerBuilder();
3434
}
@@ -44,11 +44,10 @@ public function testShouldDoNothingIfSerializerIsFound()
4444
$this->assertSame(get_class($serializer), $this->container->getDefinition('fos_rest.serializer')->getClass());
4545
}
4646

47-
/**
48-
* @expectedException \InvalidArgumentException
49-
*/
5047
public function testShouldThrowInvalidArgumentExceptionWhenNoSerializerIsFound()
5148
{
49+
$this->expectException(\InvalidArgumentException::class);
50+
5251
$compiler = new SerializerConfigurationPass();
5352
$compiler->process($this->container);
5453
}

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function incorrectExceptionCodeProvider()
245245
/**
246246
* {@inheritdoc}
247247
*/
248-
protected function setUp()
248+
protected function setUp(): void
249249
{
250250
parent::setUp();
251251
$this->configuration = new Configuration(false);

Tests/ErrorRenderer/SerializerErrorRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class SerializerErrorRendererTest extends TestCase
2626
{
27-
protected function setUp()
27+
protected function setUp(): void
2828
{
2929
if (!interface_exists(ErrorRendererInterface::class)) {
3030
$this->markTestSkipped();

Tests/EventListener/ViewResponseListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function testViewWithNoCopyDefaultVars($populateDefaultVars)
316316
}
317317
}
318318

319-
protected function setUp()
319+
protected function setUp(): void
320320
{
321321
$this->router = $this->getMockBuilder(RouterInterface::class)->getMock();
322322
$this->serializer = $this->getMockBuilder(Serializer::class)->getMock();

0 commit comments

Comments
 (0)