diff --git a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php index 51947910eb8c8c505c4639e537c35a91b0b68448..c5fc6a4283c55e218110dffa44b0cc52e2073575 100644 --- a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php +++ b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php @@ -59,9 +59,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase $this->setUpFrontendRootPage(1); $this->setUpFrontendSite(1, $this->siteLanguageConfiguration); - $this->subject = $this->getMockBuilder(LocalizationController::class) - ->setMethods(['getPageColumns']) - ->getMock(); + $this->subject = $this->getAccessibleMock(LocalizationController::class, ['getPageColumns']); } /** @@ -77,7 +75,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [1, 2, 3], 'action' => LocalizationController::ACTION_LOCALIZE, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); $this->assertAssertionDataSet('TranslatedFromDefault'); } @@ -95,7 +93,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [4, 5, 6], // uids of tt_content-danish-language 'action' => LocalizationController::ACTION_LOCALIZE, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); $this->assertAssertionDataSet('TranslatedFromTranslation'); } @@ -111,7 +109,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [1, 2, 3], 'action' => LocalizationController::ACTION_COPY, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); $this->assertAssertionDataSet('CopiedFromDefault'); } @@ -129,7 +127,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [4, 5, 6], // uids of tt_content-danish-language 'action' => LocalizationController::ACTION_COPY, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); $this->assertAssertionDataSet('CopiedFromTranslation'); } @@ -154,7 +152,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [1, 2, 3], 'action' => LocalizationController::ACTION_COPY, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); // Create another content element in default language $data = [ @@ -181,7 +179,7 @@ class LocalizationControllerTest extends AbstractDataHandlerActionTestCase 'uidList' => [$newContentElementUid], 'action' => LocalizationController::ACTION_COPY, ]; - $this->callInaccessibleMethod($this->subject, 'process', $params); + $this->subject->_call('process', $params); $this->assertAssertionDataSet('CreatedElementOrdering'); } diff --git a/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php index cc4daa109b1de6ca5a2e9654a817726c8f4c7ce8..97f2d1ccfb88ae6ebe194192eada4008b7d60f34 100644 --- a/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php +++ b/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php @@ -413,7 +413,11 @@ class ResourceStorageTest extends FunctionalTestCase self::assertSame($expectedFiles, iterator_to_array($result)); // Check if search also works for non hierarchical storages/drivers - $this->inject($subject, 'capabilities', $subject->getCapabilities() & 7); + // This is a hack, as capabilities is not settable from the outside + $objectReflection = new \ReflectionObject($subject); + $property = $objectReflection->getProperty('capabilities'); + $property->setAccessible(true); + $property->setValue('capabilities', $subject->getCapabilities() & 7); $result = $subject->searchFiles($search, $folder); $expectedFiles = array_map([$subject, 'getFile'], $expectedIdentifiers); self::assertSame($expectedFiles, iterator_to_array($result)); diff --git a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php index de514255bdcc4a6a4479f67bb4f6d5e6734f1b96..cac1305c61aaacd50d5a2c45bd00855a34c0276e 100644 --- a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php +++ b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php @@ -583,14 +583,9 @@ class DataHandlerTest extends UnitTestCase */ public function equalSubmittedAndStoredValuesAreDetermined($expected, $submittedValue, $storedValue, $storedType, $allowNull) { - $result = $this->callInaccessibleMethod( - $this->subject, - 'isSubmittedValueEqualToStoredValue', - $submittedValue, - $storedValue, - $storedType, - $allowNull - ); + $result = \Closure::bind(function () use ($submittedValue, $storedValue, $storedType, $allowNull) { + return $this->isSubmittedValueEqualToStoredValue($submittedValue, $storedValue, $storedType, $allowNull); + }, $this->subject, DataHandler::class)(); self::assertEquals($expected, $result); } diff --git a/typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php b/typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php index 5ef57a3d2903f63ff0b4afee160bb7eb618103b9..6e6a1b080a65c6e94bf12a315502a06a71c22dbe 100644 --- a/typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php +++ b/typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php @@ -1138,7 +1138,11 @@ class QueryBuilderTest extends UnitTestCase ] ] ]); - $result = $this->callInaccessibleMethod($this->subject, 'getQueriedTables'); + + // Call a protected method + $result = \Closure::bind(function () { + return $this->getQueriedTables(); + }, $this->subject, QueryBuilder::class)(); $expected = [ 'aTable' => 'aTable', @@ -1194,8 +1198,8 @@ class QueryBuilderTest extends UnitTestCase $databasePlatformProphecy = $this->prophesize($platform); $databasePlatformProphecy->getIdentifierQuoteCharacter()->willReturn($quoteChar); $connectionProphecy->getDatabasePlatform()->willReturn($databasePlatformProphecy); - $subject = GeneralUtility::makeInstance(QueryBuilder::class, $connectionProphecy->reveal()); - $result = $this->callInaccessibleMethod($subject, 'unquoteSingleIdentifier', $input); + $subject = $this->getAccessibleMock(QueryBuilder::class, ['dummy'], [$connectionProphecy->reveal()]); + $result = $subject->_call('unquoteSingleIdentifier', $input); self::assertEquals($expected, $result); } diff --git a/typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php b/typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php index 7341150ee1ebe1d0c5757d927dcecf3db716e50a..89999bd0fea60ebe62087f47f5f7b494e9b610af 100644 --- a/typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php +++ b/typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php @@ -70,7 +70,7 @@ class PackageManagerTest extends UnitTestCase ]; $this->packageManager->injectCoreCache($mockCache); - $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap); + $this->packageManager->_set('composerNameToPackageKeyMap', $composerNameToPackageKeyMap); $this->packageManager->_set('packagesBasePath', 'vfs://Test/Packages/'); $this->packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php'); } diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php index 21094b9f8955ebfa3db3ce1a0bb41141bc77033b..8e14037cadc219cce6b732b0c69794dafa607861 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php @@ -481,24 +481,23 @@ class ResourceStorageTest extends BaseTestCase public function metaDataEditIsAllowedWhenWhenInFileMount(): void { $driverMock = $this->getMockForAbstractClass(AbstractDriver::class, [], '', false); - $this->prepareSubject([], false, $driverMock, null, [], ['isWithinProcessingFolder']); + $resourceFactory = $this->prophesize(ResourceFactory::class); + $this->prepareSubject([], false, $driverMock, $resourceFactory->reveal(), [], ['isWithinProcessingFolder']); - $fileStub = new File(['identifier' => '/foo/bar.jpg'], $this->subject); $folderStub = new Folder($this->subject, '/foo/', 'foo'); + $resourceFactory->createFolderObject(Argument::cetera())->willReturn($folderStub); + $fileStub = new File(['identifier' => '/foo/bar.jpg'], $this->subject); $driverMock->expects(self::once()) ->method('isWithin') ->with($folderStub->getIdentifier(), $fileStub->getIdentifier()) ->willReturn(true); $this->subject->setEvaluatePermissions(true); - $fileMounts = [ - '/foo/' => [ - 'path' => '/foo/', - 'title' => 'Foo', - 'folder' => $folderStub, - ] - ]; - $this->inject($this->subject, 'fileMounts', $fileMounts); + $this->subject->addFileMount('/foo/', [ + 'path' => '/foo/', + 'title' => 'Foo', + 'folder' => $folderStub, + ]); self::assertTrue($this->subject->checkFileActionPermission('editMeta', $fileStub)); } @@ -508,25 +507,24 @@ class ResourceStorageTest extends BaseTestCase public function metaDataEditIsNotAllowedWhenWhenInReadOnlyFileMount(): void { $driverMock = $this->getMockForAbstractClass(AbstractDriver::class, [], '', false); - $this->prepareSubject([], false, $driverMock, null, [], ['isWithinProcessingFolder']); + $resourceFactory = $this->prophesize(ResourceFactory::class); + $this->prepareSubject([], false, $driverMock, $resourceFactory->reveal(), [], ['isWithinProcessingFolder']); $fileStub = new File(['identifier' => '/foo/bar.jpg'], $this->subject); $folderStub = new Folder($this->subject, '/foo/', 'foo'); + $resourceFactory->createFolderObject(Argument::cetera())->willReturn($folderStub); $driverMock->expects(self::once()) ->method('isWithin') ->with($folderStub->getIdentifier(), $fileStub->getIdentifier()) ->willReturn(true); $this->subject->setEvaluatePermissions(true); - $fileMounts = [ - '/foo/' => [ - 'path' => '/foo/', - 'title' => 'Foo', - 'folder' => $folderStub, - 'read_only' => true, - ] - ]; - $this->inject($this->subject, 'fileMounts', $fileMounts); + $this->subject->addFileMount('/foo/', [ + 'path' => '/foo/', + 'title' => 'Foo', + 'folder' => $folderStub, + 'read_only' => true, + ]); self::assertFalse($this->subject->checkFileActionPermission('editMeta', $fileStub)); } diff --git a/typo3/sysext/extbase/Tests/Unit/Mvc/View/JsonViewTest.php b/typo3/sysext/extbase/Tests/Unit/Mvc/View/JsonViewTest.php index 5e499225a2d228718e4aa91330f0a917cb0ffb69..2cc5d7b23dce32b1babec0216b0f6bfddbd1725b 100644 --- a/typo3/sysext/extbase/Tests/Unit/Mvc/View/JsonViewTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Mvc/View/JsonViewTest.php @@ -316,7 +316,7 @@ class JsonViewTest extends UnitTestCase }); $jsonView = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\View\JsonView::class, ['dummy'], [], '', false); - $this->inject($jsonView, 'reflectionService', $reflectionService); + $jsonView->injectReflectionService($reflectionService); $actual = $jsonView->_call('transformValue', $object, $configuration); self::assertSame($expected, $actual); } diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php index 7f9e076f354615be8d350666e79f14c507dbaddf..06a68d8f5c4f726e50b0e000112ddc6c3c6f9c63 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php @@ -81,7 +81,7 @@ class RepositoryTest extends UnitTestCase $this->mockSession = $this->createMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class); $this->mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class); $this->mockBackend = $this->getAccessibleMock(Backend::class, ['dummy'], [$this->mockConfigurationManager], '', false); - $this->inject($this->mockBackend, 'session', $this->mockSession); + $this->mockBackend->_set('session', $this->mockSession); $this->mockPersistenceManager = $this->getAccessibleMock( \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class, ['createQueryForType'], @@ -91,11 +91,11 @@ class RepositoryTest extends UnitTestCase $this->mockSession ] ); - $this->inject($this->mockBackend, 'persistenceManager', $this->mockPersistenceManager); + $this->mockBackend->setPersistenceManager($this->mockPersistenceManager); $this->mockPersistenceManager->expects(self::any())->method('createQueryForType')->willReturn($this->mockQuery); $this->mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class); $this->repository = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Repository::class, ['dummy'], [$this->mockObjectManager]); - $this->repository->_set('persistenceManager', $this->mockPersistenceManager); + $this->repository->injectPersistenceManager($this->mockPersistenceManager); } /** @@ -115,7 +115,7 @@ class RepositoryTest extends UnitTestCase $mockPersistenceManager->expects(self::once())->method('createQueryForType')->with('ExpectedType'); $this->repository->_set('objectType', 'ExpectedType'); - $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager); + $this->repository->injectPersistenceManager($mockPersistenceManager); $this->repository->createQuery(); } @@ -132,7 +132,7 @@ class RepositoryTest extends UnitTestCase $mockPersistenceManager->expects(self::exactly(2))->method('createQueryForType')->with('ExpectedType')->willReturn($mockQuery); $this->repository->_set('objectType', 'ExpectedType'); - $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager); + $this->repository->injectPersistenceManager($mockPersistenceManager); $this->repository->setDefaultOrderings($orderings); $this->repository->createQuery(); @@ -187,7 +187,7 @@ class RepositoryTest extends UnitTestCase $object = new \stdClass(); $mockPersistenceManager = $this->createMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class); $mockPersistenceManager->expects(self::once())->method('add')->with($object); - $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager); + $this->repository->injectPersistenceManager($mockPersistenceManager); $this->repository->_set('objectType', get_class($object)); $this->repository->add($object); } @@ -200,7 +200,7 @@ class RepositoryTest extends UnitTestCase $object = new \stdClass(); $mockPersistenceManager = $this->createMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class); $mockPersistenceManager->expects(self::once())->method('remove')->with($object); - $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager); + $this->repository->injectPersistenceManager($mockPersistenceManager); $this->repository->_set('objectType', get_class($object)); $this->repository->remove($object); } @@ -213,7 +213,7 @@ class RepositoryTest extends UnitTestCase $object = new \stdClass(); $mockPersistenceManager = $this->createMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class); $mockPersistenceManager->expects(self::once())->method('update')->with($object); - $this->inject($this->repository, 'persistenceManager', $mockPersistenceManager); + $this->repository->injectPersistenceManager($mockPersistenceManager); $this->repository->_set('objectType', get_class($object)); $this->repository->update($object); } diff --git a/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php b/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php index bde1d75c2f30ca43edf60aa1a0d422619141c632..2b82be06d127294427c05b4f98620054eaa2d47f 100644 --- a/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php @@ -341,7 +341,7 @@ class PropertyMapperTest extends UnitTestCase public function convertShouldAskConfigurationBuilderForDefaultConfiguration() { $propertyMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Property\PropertyMapper::class, ['dummy']); - $this->inject($propertyMapper, 'configurationBuilder', $this->mockConfigurationBuilder); + $propertyMapper->injectConfigurationBuilder($this->mockConfigurationBuilder); $this->mockConfigurationBuilder->expects(self::once())->method('build')->willReturn($this->mockConfiguration); diff --git a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ObjectConverterTest.php b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ObjectConverterTest.php index b93550536dcdfcafa79e9ef7769424468526994e..c035c252facea113da1a93bb06e1339c4a50e07e 100644 --- a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ObjectConverterTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ObjectConverterTest.php @@ -56,9 +56,9 @@ class ObjectConverterTest extends UnitTestCase $this->mockContainer = $this->createMock(\TYPO3\CMS\Extbase\Object\Container\Container::class); $this->converter = new ObjectConverter(); - $this->inject($this->converter, 'reflectionService', $this->mockReflectionService); - $this->inject($this->converter, 'objectManager', $this->mockObjectManager); - $this->inject($this->converter, 'objectContainer', $this->mockContainer); + $this->converter->injectReflectionService($this->mockReflectionService); + $this->converter->injectObjectManager($this->mockObjectManager); + $this->converter->injectObjectContainer($this->mockContainer); } /** diff --git a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/PersistentObjectConverterTest.php b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/PersistentObjectConverterTest.php index 2b307c4574d9a490c9968c49fb8694b096653a4e..42ad627d1128c3f37c8e860b91950d004699b206 100644 --- a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/PersistentObjectConverterTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/PersistentObjectConverterTest.php @@ -65,10 +65,10 @@ class PersistentObjectConverterTest extends UnitTestCase parent::setUp(); $this->converter = new PersistentObjectConverter(); $this->mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class); - $this->inject($this->converter, 'reflectionService', $this->mockReflectionService); + $this->converter->injectReflectionService($this->mockReflectionService); $this->mockPersistenceManager = $this->createMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class); - $this->inject($this->converter, 'persistenceManager', $this->mockPersistenceManager); + $this->converter->injectPersistenceManager($this->mockPersistenceManager); $this->mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class); $this->mockObjectManager->expects(self::any()) @@ -80,10 +80,10 @@ class PersistentObjectConverterTest extends UnitTestCase } return $reflectionClass->newInstanceArgs($arguments); }); - $this->inject($this->converter, 'objectManager', $this->mockObjectManager); + $this->converter->injectObjectManager($this->mockObjectManager); $this->mockContainer = $this->createMock(\TYPO3\CMS\Extbase\Object\Container\Container::class); - $this->inject($this->converter, 'objectContainer', $this->mockContainer); + $this->converter->injectObjectContainer($this->mockContainer); } /** diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Utility/ListUtilityTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Utility/ListUtilityTest.php index 700aef5e9d223ab0d74c9e2e12475dd0ac99e912..a1e138c8d2a4e6574802d05fcedf3b5e2e3c4040 100644 --- a/typo3/sysext/extensionmanager/Tests/Unit/Utility/ListUtilityTest.php +++ b/typo3/sysext/extensionmanager/Tests/Unit/Utility/ListUtilityTest.php @@ -49,7 +49,7 @@ class ListUtilityTest extends UnitTestCase 'news' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(), 'saltedpasswords' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(), ]); - $this->inject($this->subject, 'packageManager', $packageManagerMock); + $this->subject->injectPackageManager($packageManagerMock); } /** @@ -159,10 +159,10 @@ class ListUtilityTest extends UnitTestCase */ public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) { - $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(ExtensionRepository::class, ['findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'], [], '', false)); + $this->subject->injectExtensionRepository($this->getAccessibleMock(ExtensionRepository::class, ['findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'], [], '', false)); $emConfUtilityMock = $this->getMockBuilder(EmConfUtility::class)->getMock(); $emConfUtilityMock->expects(self::any())->method('includeEmConf')->willReturn($emConf); - $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock); + $this->subject->injectEmConfUtility($emConfUtilityMock); self::assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions)); } } diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php index 674459c9d4bf2895437f0750274271efaf80a510..4e69f282f480a090b9d65cb4926b0b440d564b2a 100644 --- a/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php @@ -232,11 +232,9 @@ class AbstractWidgetViewHelperTest extends UnitTestCase */ public function getWidgetConfigurationReturnsArgumentsProperty() { - $viewHelper = $this->getMockBuilder(AbstractWidgetViewHelper::class) - ->setMethods(['dummy']) - ->getMock(); + $viewHelper = $this->getAccessibleMock(AbstractWidgetViewHelper::class, ['dummy'], [], '', false); $viewHelper->setArguments(['foo' => 'bar']); - self::assertEquals(['foo' => 'bar'], $this->callInaccessibleMethod($viewHelper, 'getWidgetConfiguration')); + self::assertEquals(['foo' => 'bar'], $viewHelper->_call('getWidgetConfiguration')); } /** diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php index 012a59053cdd697340c59aaab5fbbde0957fb004..83dd25d6fef6e3af6ea823850c6c2b1ada389808 100644 --- a/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php +++ b/typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php @@ -90,8 +90,8 @@ class WidgetRequestHandlerTest extends UnitTestCase ->disableOriginalConstructor() ->getMock(); $requestDispatcher->expects(self::once())->method('dispatch')->with($request); - $this->inject($handler, 'widgetRequestBuilder', $requestBuilder); - $this->inject($handler, 'dispatcher', $requestDispatcher); + $handler->injectWidgetRequestBuilder($requestBuilder); + $handler->injectDispatcher($requestDispatcher); $handler->handleRequest(); } } diff --git a/typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php b/typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php index 145555fc75676ae53b4f930413c653b3776eba12..0b8d3dcbc20132b867d9b1dca83b6603e101ff62 100644 --- a/typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php +++ b/typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php @@ -131,12 +131,12 @@ class TemplatePathsTest extends UnitTestCase ] ] ]); - $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock(); + $subject = $this->getAccessibleMock(TemplatePaths::class, ['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode']); $subject->expects(self::once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/'); $subject->expects(self::once())->method('getConfigurationManager')->willReturn($configurationManager); $subject->expects(self::once())->method('isBackendMode')->willReturn(false); $subject->expects(self::once())->method('isFrontendMode')->willReturn(true); - $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test'); + $result = $subject->_call('getContextSpecificViewConfiguration', 'test'); self::assertSame([ 'templateRootPaths' => [ 'test/Templates/', @@ -188,12 +188,12 @@ class TemplatePathsTest extends UnitTestCase ] ] ]); - $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock(); + $subject = $this->getAccessibleMock(TemplatePaths::class, ['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode']); $subject->expects(self::once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/'); $subject->expects(self::once())->method('getConfigurationManager')->willReturn($configurationManager); $subject->expects(self::once())->method('isBackendMode')->willReturn(true); $subject->expects(self::never())->method('isFrontendMode'); - $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test'); + $result = $subject->_call('getContextSpecificViewConfiguration', 'test'); self::assertSame([ 'templateRootPaths' => [ 'test/Templates/', @@ -245,12 +245,12 @@ class TemplatePathsTest extends UnitTestCase ] ] ]); - $subject = $this->getMockBuilder(TemplatePaths::class)->setMethods(['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode'])->getMock(); + $subject = $this->getAccessibleMock(TemplatePaths::class, ['getConfigurationManager', 'getExtensionPrivateResourcesPath', 'getRuntimeCache', 'isBackendMode', 'isFrontendMode']); $subject->expects(self::once())->method('getExtensionPrivateResourcesPath')->with('test')->willReturn('test/'); $subject->expects(self::once())->method('getConfigurationManager')->willReturn($configurationManager); $subject->expects(self::once())->method('isBackendMode')->willReturn(false); $subject->expects(self::once())->method('isFrontendMode')->willReturn(false); - $result = $this->callInaccessibleMethod($subject, 'getContextSpecificViewConfiguration', 'test'); + $result = $subject->_call('getContextSpecificViewConfiguration', 'test'); self::assertSame([ 'templateRootPaths' => [ 'test/Templates/' diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Be/LinkViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Be/LinkViewHelperTest.php index b1a99ebd61644b3890f5f906babc609e210c44a5..5f5edf3432287a294cc228c761fc5e4b01340650 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Be/LinkViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Be/LinkViewHelperTest.php @@ -57,7 +57,7 @@ class LinkViewHelperTest extends ViewHelperBaseTestcase 'render' ])->getMock(); - $this->inject($this->viewHelper, 'tag', $this->tagBuilder); + $this->viewHelper->setTagBuilder($this->tagBuilder); } /** diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php index 9b6917c5213728047cb3e7e3f62b95754bc3645f..13a77a4abc1c984bba77deebe886d2230627f15b 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php @@ -106,7 +106,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase $tagBuilder->expects(self::once())->method('addAttribute')->with('action', 'foobar'); $viewHelper->_set('tag', $tagBuilder); $viewHelper->setArguments(['actionUri' => 'foobar']); - $this->callInaccessibleMethod($viewHelper, 'setFormActionUri'); + $viewHelper->_call('setFormActionUri'); } /** diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/ImageViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/ImageViewHelperTest.php index af3705257ceeb81404bd7bc70ee8f8c05e0b1e38..5666fef075aba04025ec81b72067ab625a61abb7 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/ImageViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/ImageViewHelperTest.php @@ -129,10 +129,7 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase { $this->setArgumentsUnderTest($this->viewHelper, $arguments); - $image = $this->getMockBuilder(FileReference::class) - ->setMethods(['getProperty', 'hasProperty']) - ->disableOriginalConstructor() - ->getMock(); + $image = $this->getAccessibleMock(FileReference::class, ['getProperty', 'hasProperty'], [], '', false); $image->expects(self::any())->method('hasProperty')->willReturn(true); $image->expects(self::any())->method('getProperty')->willReturnMap([ ['width', $arguments['width']], @@ -155,14 +152,14 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase ['height', $arguments['height']], ]); - $this->inject($image, 'originalFile', $originalFile); - $this->inject($image, 'propertiesOfFileReference', []); + $image->_set('originalFile', $originalFile); + $image->_set('propertiesOfFileReference', []); $imageService = $this->createMock(ImageService::class); $imageService->expects(self::once())->method('getImage')->willReturn($image); $imageService->expects(self::once())->method('applyProcessingInstructions')->with($image, self::anything())->willReturn($processedFile); $imageService->expects(self::once())->method('getImageUri')->with($processedFile)->willReturn('test.png'); - $this->inject($this->viewHelper, 'imageService', $imageService); + $this->viewHelper->injectImageService($imageService); $tagBuilder = $this->getMockBuilder(TagBuilder::class) ->setMethods(['addAttribute', 'render']) @@ -172,7 +169,7 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase $tagBuilder->expects(self::at(++ $index))->method('addAttribute')->with($expectedAttribute, $expectedValue); } $tagBuilder->expects(self::once())->method('render'); - $this->inject($this->viewHelper, 'tag', $tagBuilder); + $this->viewHelper->setTagBuilder($tagBuilder); $this->viewHelper->render(); } @@ -232,10 +229,7 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase { $this->setArgumentsUnderTest($this->viewHelper, $arguments); - $image = $this->getMockBuilder(FileReference::class) - ->setMethods(['getProperty', 'hasProperty']) - ->disableOriginalConstructor() - ->getMock(); + $image = $this->getAccessibleMock(FileReference::class, ['getProperty', 'hasProperty'], [], '', false); $image->expects(self::any())->method('hasProperty')->willReturn(false); $e = new \InvalidArgumentException('', 1556282257); @@ -255,14 +249,14 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase ['height', $arguments['height']], ]); - $this->inject($image, 'originalFile', $originalFile); - $this->inject($image, 'propertiesOfFileReference', []); + $image->_set('originalFile', $originalFile); + $image->_set('propertiesOfFileReference', []); $imageService = $this->createMock(ImageService::class); $imageService->expects(self::once())->method('getImage')->willReturn($image); $imageService->expects(self::once())->method('applyProcessingInstructions')->with($image, self::anything())->willReturn($processedFile); $imageService->expects(self::once())->method('getImageUri')->with($processedFile)->willReturn('test.png'); - $this->inject($this->viewHelper, 'imageService', $imageService); + $this->viewHelper->injectImageService($imageService); $tagBuilder = $this->getMockBuilder(TagBuilder::class) ->setMethods(['addAttribute', 'render']) @@ -272,7 +266,7 @@ class ImageViewHelperTest extends ViewHelperBaseTestcase $tagBuilder->expects(self::at(++ $index))->method('addAttribute')->with($expectedAttribute, $expectedValue); } $tagBuilder->expects(self::once())->method('render'); - $this->inject($this->viewHelper, 'tag', $tagBuilder); + $this->viewHelper->setTagBuilder($tagBuilder); $this->viewHelper->render(); } diff --git a/typo3/sysext/form/Tests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php b/typo3/sysext/form/Tests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php index ba8d6b9c496c22b951910a953057e4b7471d604f..65c4204ab920191ee2c94871d82f04305adcd38f 100644 --- a/typo3/sysext/form/Tests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php +++ b/typo3/sysext/form/Tests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php @@ -78,7 +78,7 @@ class SaveToDatabaseFinisherTest extends UnitTestCase $saveToDatabaseFinisher = $this->getMockBuilder(SaveToDatabaseFinisher::class) ->setMethods(['process']) ->getMock(); - $this->inject($saveToDatabaseFinisher, 'options', [ + $saveToDatabaseFinisher->setOptions([ 'table' => 'tx_foo', 'databaseColumnMappings' => [ 'foo' => 1, @@ -156,7 +156,7 @@ class SaveToDatabaseFinisherTest extends UnitTestCase $saveToDatabaseFinisher = $this->getMockBuilder(SaveToDatabaseFinisher::class) ->setMethods(['process']) ->getMock(); - $this->inject($saveToDatabaseFinisher, 'options', [ + $saveToDatabaseFinisher->setOptions([ [ 'table' => 'tx_foo', 'databaseColumnMappings' => [ diff --git a/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php b/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php index 32ad0cde0b1cf8ed54fb78af08c8704cc87b259d..6c01618687687dcc386df3809024f7d40880aaef 100644 --- a/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php @@ -340,12 +340,8 @@ class AbstractTypolinkBuilderTest extends UnitTestCase $this->frontendControllerMock->config = ['config' => [ 'doctype' => $doctype]]; $renderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); - $subject = $this->getMockBuilder(AbstractTypolinkBuilder::class) - ->setConstructorArgs([$renderer, $this->frontendControllerMock]) - ->setMethods(['build']) - ->getMock(); - $actual = $this->callInaccessibleMethod( - $subject, + $subject = $this->getAccessibleMockForAbstractClass(AbstractTypolinkBuilder::class, [$renderer, $this->frontendControllerMock]); + $actual = $subject->_call( 'resolveTargetAttribute', $conf, $name, diff --git a/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php b/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php index c545eb3506aed4093fb1a25e07d5d6224a8d1055..8899f18f2a2741a965e639ec24dfc8e39488fd50 100644 --- a/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php +++ b/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php @@ -706,8 +706,10 @@ class SilentConfigurationUpgradeServiceTest extends UnitTestCase $this->expectException(ConfigurationChangedException::class); $silentConfigurationUpgradeService = new SilentConfigurationUpgradeService($configurationManager->reveal()); - - $this->callInaccessibleMethod($silentConfigurationUpgradeService, 'setImageMagickDetailSettings'); + // Call protected method + \Closure::bind(function () { + return $this->setImageMagickDetailSettings(); + }, $silentConfigurationUpgradeService, SilentConfigurationUpgradeService::class)(); } /**