diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index 84c55119e85eb05a22176cc04793210161cbd820..b86feb330db7ea526deaf2c8dbbb8afa6110e6df 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -1307,7 +1307,7 @@ parameters: - message: "#^Parameter \\#1 \\$uid of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\AbstractRepository\\<object\\>\\:\\:findByUid\\(\\) expects int, string given\\.$#" - count: 2 + count: 1 path: ../../typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php - diff --git a/typo3/sysext/core/Tests/Unit/Log/Processor/AbstractMemoryProcessorTest.php b/typo3/sysext/core/Tests/Unit/Log/Processor/AbstractMemoryProcessorTest.php index 178b2292d500d35f53fb98f6e4aa75a827a4c381..5f5f61e6e0d7e3ed3bf42bd3e009275bb76c8faf 100644 --- a/typo3/sysext/core/Tests/Unit/Log/Processor/AbstractMemoryProcessorTest.php +++ b/typo3/sysext/core/Tests/Unit/Log/Processor/AbstractMemoryProcessorTest.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Log\Processor; -use TYPO3\CMS\Core\Log\Processor\AbstractMemoryProcessor; +use TYPO3\CMS\Core\Tests\Unit\Log\Processor\Fixtures\TestingMemoryProcessor; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class AbstractMemoryProcessorTest extends UnitTestCase @@ -27,7 +27,7 @@ final class AbstractMemoryProcessorTest extends UnitTestCase */ public function setRealMemoryUsageSetsRealMemoryUsage(): void { - $processor = $this->getMockForAbstractClass(AbstractMemoryProcessor::class); + $processor = new TestingMemoryProcessor(); $processor->setRealMemoryUsage(false); self::assertFalse($processor->getRealMemoryUsage()); } @@ -37,7 +37,7 @@ final class AbstractMemoryProcessorTest extends UnitTestCase */ public function setFormatSizeSetsFormatSize(): void { - $processor = $this->getMockForAbstractClass(AbstractMemoryProcessor::class); + $processor = new TestingMemoryProcessor(); $processor->setFormatSize(false); self::assertFalse($processor->getFormatSize()); } diff --git a/typo3/sysext/core/Tests/Unit/Log/Processor/Fixtures/TestingMemoryProcessor.php b/typo3/sysext/core/Tests/Unit/Log/Processor/Fixtures/TestingMemoryProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..0bc37c0b4fa655f9098122fa204f35055666e5cd --- /dev/null +++ b/typo3/sysext/core/Tests/Unit/Log/Processor/Fixtures/TestingMemoryProcessor.php @@ -0,0 +1,32 @@ +<?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\Core\Tests\Unit\Log\Processor\Fixtures; + +use TYPO3\CMS\Core\Log\LogRecord; +use TYPO3\CMS\Core\Log\Processor\AbstractMemoryProcessor; + +/** + * Testing subclass of `AbstractMemoryProcessor`. + */ +final class TestingMemoryProcessor extends AbstractMemoryProcessor +{ + public function processLogRecord(LogRecord $logRecord): LogRecord + { + throw new \BadMethodCallException('Not implemented', 1691578434); + } +} diff --git a/typo3/sysext/core/Tests/Unit/Resource/AbstractFileTest.php b/typo3/sysext/core/Tests/Unit/Resource/AbstractFileTest.php index c46dbe82e5c3d7f14fdf89be5241fb8bb36d08dc..c2e499cf1423bcadb554d95e661efa33915f4d3f 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/AbstractFileTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/AbstractFileTest.php @@ -17,10 +17,10 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Resource; -use TYPO3\CMS\Core\Resource\AbstractFile; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FolderInterface; use TYPO3\CMS\Core\Resource\ResourceStorage; +use TYPO3\CMS\Core\Tests\Unit\Resource\Fixtures\TestingFile; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; /** @@ -48,7 +48,7 @@ final class AbstractFileTest extends UnitTestCase $mockedStorage->expects(self::once())->method('getFolderIdentifierFromFileIdentifier')->with($currentIdentifier)->willReturn($parentIdentifier); $mockedStorage->expects(self::once())->method('getFolder')->with($parentIdentifier)->willReturn($parentFolderFixture); - $currentFolderFixture = $this->getMockForAbstractClass(AbstractFile::class); + $currentFolderFixture = new TestingFile(); $currentFolderFixture->setIdentifier($currentIdentifier)->setStorage($mockedStorage); self::assertSame($parentFolderFixture, $currentFolderFixture->getParentFolder()); diff --git a/typo3/sysext/core/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php b/typo3/sysext/core/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php index 7075686e5ccd7690f82d646d427ac16c043bc8df..2b5739c728bf4ad94ef74128313ed3f1b62c50bc 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Collection/FileCollectionRegistryTest.php @@ -17,9 +17,9 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Resource\Collection; -use TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection; use TYPO3\CMS\Core\Resource\Collection\FileCollectionRegistry; use TYPO3\CMS\Core\Resource\Collection\StaticFileCollection; +use TYPO3\CMS\Core\Tests\Unit\Resource\Collection\Fixtures\TestingFileCollection; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -30,7 +30,7 @@ final class FileCollectionRegistryTest extends UnitTestCase */ public function registeredFileCollectionClassesCanBeRetrieved(): void { - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $subject = new FileCollectionRegistry(); $subject->registerFileCollectionClass($className, 'foobar'); $returnedClassName = $subject->getFileCollectionClass('foobar'); @@ -56,7 +56,7 @@ final class FileCollectionRegistryTest extends UnitTestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1391295611); $subject = new FileCollectionRegistry(); - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $type = str_pad('', 40); $subject->registerFileCollectionClass($className, $type); } @@ -69,7 +69,7 @@ final class FileCollectionRegistryTest extends UnitTestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1391295643); $subject = new FileCollectionRegistry(); - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $className2 = get_class($this->getMockForAbstractClass(StaticFileCollection::class)); $subject->registerFileCollectionClass($className, 'foobar'); $subject->registerFileCollectionClass($className2, 'foobar'); @@ -80,7 +80,7 @@ final class FileCollectionRegistryTest extends UnitTestCase */ public function registerFileCollectionClassOverridesExistingRegisteredFileCollectionClass(): void { - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $className2 = get_class($this->getMockForAbstractClass(StaticFileCollection::class)); $subject = new FileCollectionRegistry(); $subject->registerFileCollectionClass($className, 'foobar'); @@ -103,7 +103,7 @@ final class FileCollectionRegistryTest extends UnitTestCase */ public function getFileCollectionClassAcceptsClassNameIfClassIsRegistered(): void { - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $subject = new FileCollectionRegistry(); $subject->registerFileCollectionClass($className, 'foobar'); self::assertEquals($className, $subject->getFileCollectionClass('foobar')); @@ -114,7 +114,7 @@ final class FileCollectionRegistryTest extends UnitTestCase */ public function fileCollectionRegistryIsInitializedWithPreconfiguredFileCollections(): void { - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $type = substr(StringUtility::getUniqueId('type_'), 0, 30); $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredCollections'] = [ $type => $className, @@ -128,7 +128,7 @@ final class FileCollectionRegistryTest extends UnitTestCase */ public function fileCollectionExistsReturnsTrueForAllExistingFileCollections(): void { - $className = get_class($this->getMockForAbstractClass(AbstractFileCollection::class)); + $className = TestingFileCollection::class; $type = 'foo'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredCollections'] = [ $type => $className, diff --git a/typo3/sysext/core/Tests/Unit/Resource/Collection/Fixtures/TestingFileCollection.php b/typo3/sysext/core/Tests/Unit/Resource/Collection/Fixtures/TestingFileCollection.php new file mode 100644 index 0000000000000000000000000000000000000000..2ac7ddef960a74baa11d8891b7b1385927ed2d81 --- /dev/null +++ b/typo3/sysext/core/Tests/Unit/Resource/Collection/Fixtures/TestingFileCollection.php @@ -0,0 +1,31 @@ +<?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\Core\Tests\Unit\Resource\Collection\Fixtures; + +use TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection; + +/** + * Testing subclass of `AbstractFileCollection`. + */ +final class TestingFileCollection extends AbstractFileCollection +{ + public function loadContents(): void + { + // stub + } +} diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php index 0a8a1508941c7e9de9ed98912796d98c1d971862..f4125bb462188666f5f838bce6795d475f07a77d 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractDriverTest.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver; -use TYPO3\CMS\Core\Resource\Driver\AbstractDriver; +use TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\TestingDriver; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class AbstractDriverTest extends UnitTestCase @@ -27,7 +27,7 @@ final class AbstractDriverTest extends UnitTestCase */ public function isCaseSensitiveFileSystemReturnsTrueIfNothingIsConfigured(): void { - $subject = $this->getMockForAbstractClass(AbstractDriver::class, [], '', false); + $subject = new TestingDriver(); self::assertTrue($subject->isCaseSensitiveFileSystem()); } } diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php index 33bd8d0d932dd6742e9e597c9c46c1645837d6db..582b4c43fd650383f7d65444d704669c7b8af739 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/DriverRegistryTest.php @@ -19,6 +19,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver; use TYPO3\CMS\Core\Resource\Driver\DriverInterface; use TYPO3\CMS\Core\Resource\Driver\DriverRegistry; +use TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\TestingDriver; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -55,7 +56,7 @@ final class DriverRegistryTest extends UnitTestCase $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1314979451); $className = get_class($this->createMock(DriverInterface::class)); - $className2 = get_class($this->getMockForAbstractClass(DriverInterface::class)); + $className2 = TestingDriver::class; $subject = new DriverRegistry(); $subject->registerDriverClass($className, 'foobar'); $subject->registerDriverClass($className2, 'foobar'); diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/TestingDriver.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/TestingDriver.php new file mode 100644 index 0000000000000000000000000000000000000000..18997fe1d97882387684630590aed46ffb20841e --- /dev/null +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/Fixtures/TestingDriver.php @@ -0,0 +1,281 @@ +<?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\Core\Tests\Unit\Resource\Driver\Fixtures; + +use TYPO3\CMS\Core\Resource\Capabilities; +use TYPO3\CMS\Core\Resource\Driver\AbstractDriver; + +/** + * Testing subclass of `AbstractDriver`. + */ +final class TestingDriver extends AbstractDriver +{ + protected function canonicalizeAndCheckFilePath(string $filePath): string + { + throw new \BadMethodCallException('Not implemented', 1691577284); + } + + protected function canonicalizeAndCheckFileIdentifier(string $fileIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577288); + } + + protected function canonicalizeAndCheckFolderIdentifier(string $folderIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577293); + } + + public function processConfiguration(): void + { + // stub + } + + public function initialize(): void + { + // stub + } + + public function mergeConfigurationCapabilities(Capabilities $capabilities): Capabilities + { + throw new \BadMethodCallException('Not implemented', 1691577300); + } + + public function sanitizeFileName(string $fileName, string $charset = ''): string + { + throw new \BadMethodCallException('Not implemented', 1691577304); + } + + public function getRootLevelFolder(): string + { + throw new \BadMethodCallException('Not implemented', 1691577309); + } + + public function getDefaultFolder(): string + { + throw new \BadMethodCallException('Not implemented', 1691577316); + } + + public function getParentFolderIdentifierOfIdentifier(string $fileIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577324); + } + + public function getPublicUrl(string $identifier): ?string + { + throw new \BadMethodCallException('Not implemented', 1691577328); + } + + public function createFolder( + string $newFolderName, + string $parentFolderIdentifier = '', + bool $recursive = false + ): string { + throw new \BadMethodCallException('Not implemented', 1691577334); + } + + public function renameFolder(string $folderIdentifier, string $newName): array + { + throw new \BadMethodCallException('Not implemented', 1691577338); + } + + public function deleteFolder(string $folderIdentifier, bool $deleteRecursively = false): bool + { + throw new \BadMethodCallException('Not implemented', 1691577342); + } + + public function fileExists(string $fileIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577347); + } + + public function folderExists(string $folderIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577350); + } + + public function isFolderEmpty(string $folderIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577354); + } + + public function addFile( + string $localFilePath, + string $targetFolderIdentifier, + string $newFileName = '', + bool $removeOriginal = true + ): string { + throw new \BadMethodCallException('Not implemented', 1691577360); + } + + public function createFile(string $fileName, string $parentFolderIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577364); + } + + public function copyFileWithinStorage( + string $fileIdentifier, + string $targetFolderIdentifier, + string $fileName + ): string { + throw new \BadMethodCallException('Not implemented', 1691577369); + } + + public function renameFile(string $fileIdentifier, string $newName): string + { + throw new \BadMethodCallException('Not implemented', 1691577375); + } + + public function replaceFile(string $fileIdentifier, string $localFilePath): bool + { + throw new \BadMethodCallException('Not implemented', 1691577379); + } + + public function deleteFile(string $fileIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577384); + } + + public function hash(string $fileIdentifier, string $hashAlgorithm): string + { + throw new \BadMethodCallException('Not implemented', 1691577388); + } + + public function moveFileWithinStorage( + string $fileIdentifier, + string $targetFolderIdentifier, + string $newFileName + ): string { + throw new \BadMethodCallException('Not implemented', 1691577393); + } + + public function moveFolderWithinStorage( + string $sourceFolderIdentifier, + string $targetFolderIdentifier, + string $newFolderName + ): array { + throw new \BadMethodCallException('Not implemented', 1691577398); + } + + public function copyFolderWithinStorage( + string $sourceFolderIdentifier, + string $targetFolderIdentifier, + string $newFolderName + ): bool { + throw new \BadMethodCallException('Not implemented', 1691577402); + } + + public function getFileContents(string $fileIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577406); + } + + public function setFileContents(string $fileIdentifier, string $contents): int + { + throw new \BadMethodCallException('Not implemented', 1691577411); + } + + public function fileExistsInFolder(string $fileName, string $folderIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577414); + } + + public function folderExistsInFolder(string $folderName, string $folderIdentifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577418); + } + + public function getFileForLocalProcessing(string $fileIdentifier, bool $writable = true): string + { + throw new \BadMethodCallException('Not implemented', 1691577423); + } + + public function getPermissions(string $identifier): array + { + throw new \BadMethodCallException('Not implemented', 1691577427); + } + + public function dumpFileContents(string $identifier): void + { + // stub + } + + public function isWithin(string $folderIdentifier, string $identifier): bool + { + throw new \BadMethodCallException('Not implemented', 1691577435); + } + + public function getFileInfoByIdentifier(string $fileIdentifier, array $propertiesToExtract = []): array + { + throw new \BadMethodCallException('Not implemented', 1691577440); + } + + public function getFolderInfoByIdentifier(string $folderIdentifier): array + { + throw new \BadMethodCallException('Not implemented', 1691577444); + } + + public function getFileInFolder(string $fileName, string $folderIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577449); + } + + public function getFilesInFolder( + string $folderIdentifier, + int $start = 0, + int $numberOfItems = 0, + bool $recursive = false, + array $filenameFilterCallbacks = [], + string $sort = '', + bool $sortRev = false + ): array { + throw new \BadMethodCallException('Not implemented', 1691577453); + } + + public function getFolderInFolder(string $folderName, string $folderIdentifier): string + { + throw new \BadMethodCallException('Not implemented', 1691577457); + } + + public function getFoldersInFolder( + string $folderIdentifier, + int $start = 0, + int $numberOfItems = 0, + bool $recursive = false, + array $folderNameFilterCallbacks = [], + string $sort = '', + bool $sortRev = false + ): array { + throw new \BadMethodCallException('Not implemented', 1691577462); + } + + public function countFilesInFolder( + string $folderIdentifier, + bool $recursive = false, + array $filenameFilterCallbacks = [] + ): int { + throw new \BadMethodCallException('Not implemented', 1691577466); + } + + public function countFoldersInFolder( + string $folderIdentifier, + bool $recursive = false, + array $folderNameFilterCallbacks = [] + ): int { + throw new \BadMethodCallException('Not implemented', 1691577470); + } +} diff --git a/typo3/sysext/core/Tests/Unit/Resource/Fixtures/TestingFile.php b/typo3/sysext/core/Tests/Unit/Resource/Fixtures/TestingFile.php new file mode 100644 index 0000000000000000000000000000000000000000..e8e5930a7726ea115cb38466c612b8894ef7f56a --- /dev/null +++ b/typo3/sysext/core/Tests/Unit/Resource/Fixtures/TestingFile.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\Core\Tests\Unit\Resource\Fixtures; + +use TYPO3\CMS\Core\Resource\AbstractFile; + +/** + * Testing subclass of `AbstractFile`. + */ +final class TestingFile extends AbstractFile +{ + public function updateProperties(array $properties): void + { + // stub + } + + public function isIndexed(): bool + { + throw new \BadMethodCallException('Not implemented', 1691576988); + } + + public function toArray(): array + { + throw new \BadMethodCallException('Not implemented', 1691580005); + } +} diff --git a/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php index e102bb21f1242c8dbd7b816c86ef52bbffd3c9fc..b134653779236d3b5a56cd9ba4ff9b2bf6270a96 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php @@ -17,13 +17,12 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Resource\Repository; -use Doctrine\DBAL\Result; use PHPUnit\Framework\MockObject\MockObject; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; use TYPO3\CMS\Core\Database\Query\QueryBuilder; -use TYPO3\CMS\Core\Resource\AbstractRepository; +use TYPO3\CMS\Core\Tests\Unit\Resource\Repository\Fixtures\TestingRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -53,26 +52,7 @@ final class AbstractRepositoryTest extends UnitTestCase { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1316779798); - $subject = $this->getMockForAbstractClass(AbstractRepository::class, [], '', false); + $subject = new TestingRepository(); $subject->findByUid('asdf'); } - - /** - * @test - */ - public function findByUidAcceptsNumericUidInString(): void - { - $statementMock = $this->createMock(Result::class); - $statementMock->expects(self::once())->method('fetchAssociative')->willReturn(['uid' => 123]); - - $queryBuilderMock = $this->createDatabaseMock(); - $queryBuilderMock->expects(self::once())->method('select')->with('*')->willReturn($queryBuilderMock); - $queryBuilderMock->expects(self::once())->method('from')->with('')->willReturn($queryBuilderMock); - $queryBuilderMock->expects(self::once())->method('where')->with(self::anything())->willReturn($queryBuilderMock); - $queryBuilderMock->method('createNamedParameter')->with(self::anything())->willReturnArgument(0); - $queryBuilderMock->expects(self::once())->method('executeQuery')->willReturn($statementMock); - - $subject = $this->getMockForAbstractClass(AbstractRepository::class, [], '', false); - $subject->findByUid('123'); - } } diff --git a/typo3/sysext/core/Tests/Unit/Resource/Repository/Fixtures/TestingRepository.php b/typo3/sysext/core/Tests/Unit/Resource/Repository/Fixtures/TestingRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..362f96bf455bc988291818b5cdde8bce4d232a35 --- /dev/null +++ b/typo3/sysext/core/Tests/Unit/Resource/Repository/Fixtures/TestingRepository.php @@ -0,0 +1,36 @@ +<?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\Core\Tests\Unit\Resource\Repository\Fixtures; + +use TYPO3\CMS\Core\Resource\AbstractRepository; + +/** + * Testing subclass of `AbstractRepository`. + */ +final class TestingRepository extends AbstractRepository +{ + public function __construct() + { + // Do not call parent constructor + } + + protected function createDomainObject(array $databaseRow): object + { + throw new \BadMethodCallException('Not implemented', 1691578354); + } +} diff --git a/typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php index a83077d1df2279301a4d1f4b09b400477317026e..b265b71192c102ebe9fcb912f3d868f73a2f0a26 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php @@ -19,7 +19,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility; use PHPUnit\Framework\MockObject\MockObject; use TYPO3\CMS\Core\Cache\CacheManager; -use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend; use TYPO3\CMS\Core\Cache\Frontend\NullFrontend; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\LanguageAspect; @@ -319,18 +318,11 @@ final class RootlineUtilityTest extends UnitTestCase public function getCacheIdentifierReturnsValidIdentifierWithCommasInMountPointParameter(): void { $this->subject->method('resolvePageId')->willReturn(42); - - $cacheFrontendMock = $this->getMockForAbstractClass( - AbstractFrontend::class, - [], - '', - false - ); + $cacheFrontend = new NullFrontend('some-frontend'); $context = new Context(); $context->setAspect('workspace', new WorkspaceAspect(15)); $context->setAspect('language', new LanguageAspect(8, 8, LanguageAspect::OVERLAYS_OFF)); - $this->subject->__construct(42, '47-11,48-12', $context); - self::assertTrue($cacheFrontendMock->isValidEntryIdentifier($this->subject->getCacheIdentifier())); + self::assertTrue($cacheFrontend->isValidEntryIdentifier($this->subject->getCacheIdentifier())); } }