8000 minor #54824 Fix various warnings across components test suite (alexa… · symfony/symfony@32b631c · GitHub
[go: up one dir, main page]

Skip to content

Commit 32b631c

Browse files
committed
minor #54824 Fix various warnings across components test suite (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- Fix various warnings across components test suite | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT We found out with `@xabbuh` that some warnings are "hidden" in the test suite of 5.4. Indeed, a risky test was raised in upper branches (starting from 6.4). However, this test was not marked as risky in the 5.4 branch. The reproducer is straightforward: - `vendor/bin/phpunit src/Symfony/Component/Serializer` marked the test as risky. - `./phpunit src/Symfony/Component/Serializer` did **not** mark the test as risky. I went through components and bundle and executed PHPUnit to fix various warnings and deprecations hidden in the 5.4 CI. We don't know yet why 5.4 behaves this way. In the meantime, here are a few fixes of deprecated behaviors I found. Commits ------- a6fe93c Fix various warnings across components test suite
2 parents ddf3489 + a6fe93c commit 32b631c

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function tearDownAfterClass(): void
3333
static::deleteTmpDir();
3434
}
3535

36-
public function provideSecuritySystems()
36+
public static function provideSecuritySystems()
3737
{
3838
yield [['enable_authenticator_manager' => true]];
3939
yield [['enable_authenticator_manager' => false]];

src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testSupports()
4646
*/
4747
public function testIsFresh(callable $mockContainer, $expected)
4848
{
49-
$mockContainer($this->container);
49+
$mockContainer($this->container, $this);
5050

5151
$this->assertSame($expected, $this->resourceChecker->isFresh($this->resource, time()));
5252
}
@@ -61,9 +61,9 @@ public static function isFreshProvider()
6161
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
6262
}, false];
6363

64-
yield 'fresh on every identical parameters' => [function (MockObject $container) {
65-
$container->expects(self::exactly(2))->method('hasParameter')->willReturn(true);
66-
$container->expects(self::exactly(2))->method('getParameter')
64+
yield 'fresh on every identical parameters' => [function (MockObject $container, TestCase $testCase) {
65+
$container->expects($testCase->exactly(2))->method('hasParameter')->willReturn(true);
66+
$container->expects($testCase->exactly(2))->method('getParameter')
6767
->willReturnCallback(function (...$args) {
6868
static $series = [
6969
[['locales'], ['fr', 'en']],

src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ public function testNestedBundleConfigNotAllowed()
194194
*/
195195
public function testWhenEnv()
196196
{
197+
$this->expectNotToPerformAssertions();
198+
197199
$fixtures = realpath(__DIR__.'/../Fixtures');
198200
$container = new ContainerBuilder();
199201
$loader = new PhpFileLoader($container, new FileLocator(), 'dev', new ConfigBuilderGenerator(sys_get_temp_dir()));

src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ protected function tearDown(): void
6363
parent::tearDown();
6464

6565
@unlink($this->testTmpFilepath);
66+
@unlink($this->largeTestTmpFilepath);
6667

6768
$this->routeCollection = null;
6869
$this->generatorDumper = null;
6970
$this->testTmpFilepath = null;
71+
$this->largeTestTmpFilepath = null;
7072
}
7173

7274
public function testDumpWithRoutes()

src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ public function testUncallableCallbacks($callbacks)
126126
$normalizer->normalize($obj, null, ['callbacks' => $callbacks]);
127127
}
128128

129-
public function provideNormalizeCallbacks()
129+
public static function provideNormalizeCallbacks()
130130
{
131131
return [
132132
'Change a string' => [
133133
[
134134
'bar' => function ($bar) {
135-
$this->assertEquals('baz', $bar);
135+
static::assertEquals('baz', $bar);
136136

137137
return 'baz';
138138
},
@@ -143,11 +143,11 @@ public function provideNormalizeCallbacks()
143143
'Null an item' => [
144144
[
145145
'bar' => function ($value, $object, $attributeName, $format, $context) {
146-
$this->assertSame('baz', $value);
147-
$this->assertInstanceOf(CallbacksObject::class, $object);
148-
$this->assertSame('bar', $attributeName);
149-
$this->assertSame('any', $format);
150-
$this->assertArrayHasKey('circular_reference_limit_counters', $context);
146+
static::assertSame('baz', $value);
147+
static::assertInstanceOf(CallbacksObject::class, $object);
148+
static::assertSame('bar', $attributeName);
149+
static::assertSame('any', $format);
150+
static::assertArrayHasKey('circular_reference_limit_counters', $context);
151151
},
152152
],
153153
'baz',
@@ -156,7 +156,7 @@ public function provideNormalizeCallbacks()
156156
'Format a date' => [
157157
[
158158
'bar' => function ($bar) {
159-
$this->assertInstanceOf(\DateTime::class, $bar);
159+
static::assertInstanceOf(\DateTime::class, $bar);
160160

161161
return $bar->format('d-m-Y H:i:s');
162162
},
@@ -190,13 +190,13 @@ public function provideNormalizeCallbacks()
190190
];
191191
}
192192

193-
public function provideDenormalizeCallbacks(): array
193+
public static function provideDenormalizeCallbacks(): array
194194
{
195195
return [
196196
'Change a string' => [
197197
[
198198
'bar' => function ($bar) {
199-
$this->assertEquals('bar', $bar);
199+
static::assertEquals('bar', $bar);
200200

201201
return $bar;
202202
},
@@ -207,11 +207,11 @@ public function provideDenormalizeCallbacks(): array
207207
'Null an item' => [
208208
[
209209
'bar' => function ($value, $object, $attributeName, $format, $context) {
210-
$this->assertSame('baz', $value);
211-
$this->assertTrue(is_a($object, CallbacksObject::class, true));
212-
$this->assertSame('bar', $attributeName);
213-
$this->assertSame('any', $format);
214-
$this->assertIsArray($context);
210+
static::assertSame('baz', $value);
211+
static::assertTrue(is_a($object, CallbacksObject::class, true));
212+
static::assertSame('bar', $attributeName);
213+
static::assertSame('any', $format);
214+
static::assertIsArray($context);
215215
},
216216
],
217217
'baz',
@@ -220,7 +220,7 @@ public function provideDenormalizeCallbacks(): array
220220
'Format a date' => [
221221
[
222222
'bar' => function ($bar) {
223-
$this->assertIsString($bar);
223+
static::assertIsString($bar);
224224

225225
return \DateTime::createFromFormat('d-m-Y H:i:s', $bar);
226226
},
@@ -254,13 +254,13 @@ public function provideDenormalizeCallbacks(): array
254254
];
255255
}
256256

257-
public function providerDenormalizeCallbacksWithTypedProperty(): array
257+
public static function providerDenormalizeCallbacksWithTypedProperty(): array
258258
{
259259
return [
260260
'Change a typed string' => [
261261
[
262262
'foo' => function ($foo) {
263-
$this->assertEquals('foo', $foo);
263+
static::assertEquals('foo', $foo);
264264

265265
return $foo;
266266
},
@@ -271,11 +271,11 @@ public function providerDenormalizeCallbacksWithTypedProperty(): array
271271
'Null an typed item' => [
272272
[
273273
'foo' => function ($value, $object, $attributeName, $format, $context) {
274-
$this->assertSame('fool', $value);
275-
$this->assertTrue(is_a($object, CallbacksObject::class, true));
276-
$this->assertSame('foo', $attributeName);
277-
$this->assertSame('any', $format);
278-
$this->assertIsArray($context);
274+
static::assertSame('fool', $value);
275+
static::assertTrue(is_a($object, CallbacksObj F42D ect::class, true));
276+
static::assertSame('foo', $attributeName);
277+
static::assertSame('any', $format);
278+
static::assertIsArray($context);
279279
},
280280
],
281281
'fool',
@@ -284,7 +284,7 @@ public function providerDenormalizeCallbacksWithTypedProperty(): array
284284
];
285285
}
286286

287-
public function provideInvalidCallbacks()
287+
public static function provideInvalidCallbacks()
288288
{
289289
return [
290290
[['bar' => null]],

src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract protected function getNormalizerForCircularReference(array $defaultCont
2323

2424
abstract protected function getSelfReferencingModel();
2525

26-
public function provideUnableToNormalizeCircularReference(): array
26+
public static function provideUnableToNormalizeCircularReference(): array
2727
{
2828
return [
2929
[[], [], 1],

src/Symfony/Component/Serializer/Tests/Normalizer/Features/SkipUninitializedValuesTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testSkipUninitializedValues(array $context)
4444
$this->assertSame('value', $objectToPopulate->getUninitialized());
4545
}
4646

47-
public function skipUninitializedValuesFlagProvider(): iterable
47+
public static function skipUninitializedValuesFlagProvider(): iterable
4848
{
4949
yield 'passed manually' => [['skip_uninitialized_values' => true, 'groups' => ['foo']]];
5050
yield 'using default context value' => [['groups' => ['foo']]];

0 commit comments

Comments
 (0)
0