From e93f67bd62123527fa1c662d465f5f7c30c330df Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 11 Aug 2023 16:08:13 +0200 Subject: [PATCH] [TASK] Migrate `getMockForAbstractClass()` calls in `EXT:core` `getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1: https://github.com/sebastianbergmann/phpunit/issues/5241 Hence, we should replace its usages to follow best practices and avoid deprecation warnings later with PHPUnit 11. We do this by creating dedicated fixture subclasses of the affected abstract classes. Resolves: #101666 Related: #101601 Releases: main, 12.4 Change-Id: I0263ff7b0639d72ba1d4f30e3bee12276d364591 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80946 Tested-by: Benjamin Franzke Tested-by: core-ci Reviewed-by: Benjamin Franzke --- .../Collection/FileCollectionRegistryTest.php | 6 ++-- .../Fixtures/OtherTestingFileCollection.php | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 Tests/Unit/Resource/Collection/Fixtures/OtherTestingFileCollection.php diff --git a/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php b/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php index 2b5739c728..46deb0860e 100644 --- a/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php +++ b/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php @@ -18,7 +18,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Collection; use TYPO3\CMS\Core\Resource\Collection\FileCollectionRegistry; -use TYPO3\CMS\Core\Resource\Collection\StaticFileCollection; +use TYPO3\CMS\Core\Tests\Unit\Resource\Collection\Fixtures\OtherTestingFileCollection; use TYPO3\CMS\Core\Tests\Unit\Resource\Collection\Fixtures\TestingFileCollection; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -70,7 +70,7 @@ public function registerFileCollectionClassThrowsExceptionIfTypeIsAlreadyRegiste $this->expectExceptionCode(1391295643); $subject = new FileCollectionRegistry(); $className = TestingFileCollection::class; - $className2 = get_class($this->getMockForAbstractClass(StaticFileCollection::class)); + $className2 = OtherTestingFileCollection::class; $subject->registerFileCollectionClass($className, 'foobar'); $subject->registerFileCollectionClass($className2, 'foobar'); } @@ -81,7 +81,7 @@ public function registerFileCollectionClassThrowsExceptionIfTypeIsAlreadyRegiste public function registerFileCollectionClassOverridesExistingRegisteredFileCollectionClass(): void { $className = TestingFileCollection::class; - $className2 = get_class($this->getMockForAbstractClass(StaticFileCollection::class)); + $className2 = OtherTestingFileCollection::class; $subject = new FileCollectionRegistry(); $subject->registerFileCollectionClass($className, 'foobar'); $subject->registerFileCollectionClass($className2, 'foobar', true); diff --git a/Tests/Unit/Resource/Collection/Fixtures/OtherTestingFileCollection.php b/Tests/Unit/Resource/Collection/Fixtures/OtherTestingFileCollection.php new file mode 100644 index 0000000000..95a2db1731 --- /dev/null +++ b/Tests/Unit/Resource/Collection/Fixtures/OtherTestingFileCollection.php @@ -0,0 +1,33 @@ +