From c53a565da35f9adc98f2c740086a7d6f48ded147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech> Date: Tue, 6 Sep 2022 18:15:36 +0200 Subject: [PATCH] [TASK] Avoid PHP8.2 related deprecation failure in unit test With PHP8.2 setting dynamic properties has been deprecated. This is also valid if it is set through unserialization and emits a deprecation warning. Thus this fails hard in tests. Thus one test fails, which is expclicitly testing unserialization with invalid dynamic class properties. This change moves the test to unitDeprecated tests, which will not fail on deprecation warnings. This acts pre-patch to update PHP8.2 testing to `PHP8.2.0 RC1`. Resolves: #98266 Releases: main, 11.5 Change-Id: I7bf87b0ade906727f6222d31a1b735f452717138 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75616 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> --- .../Unit/Reflection/ReflectionServiceTest.php | 15 ------- .../InsecureSerializedReflectionService.txt | 0 .../Reflection/ReflectionServiceTest.php | 41 +++++++++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) rename typo3/sysext/extbase/Tests/{Unit => UnitDeprecated}/Reflection/Fixture/InsecureSerializedReflectionService.txt (100%) create mode 100644 typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/ReflectionServiceTest.php diff --git a/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php b/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php index 6de22336d5ec..d406e68f80af 100644 --- a/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php @@ -94,19 +94,4 @@ class ReflectionServiceTest extends UnitTestCase self::assertInstanceOf(ReflectionService::class, $reflectionService); self::assertInstanceOf(ClassSchema::class, $reflectionService->getClassSchema($class)); } - - /** - * @test - */ - public function reflectionServiceIsResetDuringWakeUp(): void - { - $insecureString = file_get_contents(__DIR__ . '/Fixture/InsecureSerializedReflectionService.txt'); - $reflectionService = unserialize($insecureString); - - $reflectionClass = new \ReflectionClass($reflectionService); - $classSchemaProperty = $reflectionClass->getProperty('classSchemata'); - $classSchemaProperty->setAccessible(true); - - self::assertSame([], $classSchemaProperty->getValue($reflectionService)); - } } diff --git a/typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/InsecureSerializedReflectionService.txt b/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/Fixture/InsecureSerializedReflectionService.txt similarity index 100% rename from typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/InsecureSerializedReflectionService.txt rename to typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/Fixture/InsecureSerializedReflectionService.txt diff --git a/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/ReflectionServiceTest.php b/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/ReflectionServiceTest.php new file mode 100644 index 000000000000..45c6ee165fdc --- /dev/null +++ b/typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/ReflectionServiceTest.php @@ -0,0 +1,41 @@ +<?php + +declare(strict_types=1); + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +namespace TYPO3\CMS\Extbase\Tests\UnitDeprecated\Reflection; + +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + +class ReflectionServiceTest extends UnitTestCase +{ + /** + * @test + * + * Note: Starting with PHP8.2 unserializing dynamic properties (undefined properties) emits a deprecation + * warning, which fails in normal tests. This moved here to avoid failing tests. + */ + public function reflectionServiceIsResetDuringWakeUp(): void + { + $insecureString = file_get_contents(__DIR__ . '/Fixture/InsecureSerializedReflectionService.txt'); + $reflectionService = unserialize($insecureString); + + $reflectionClass = new \ReflectionClass($reflectionService); + $classSchemaProperty = $reflectionClass->getProperty('classSchemata'); + $classSchemaProperty->setAccessible(true); + + self::assertSame([], $classSchemaProperty->getValue($reflectionService)); + } +} -- GitLab