From 54f07bfbeddd149e330e28d8fd92e9b1293a6670 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Fri, 29 Nov 2019 15:46:36 +0100 Subject: [PATCH] [TASK] Migrate Tests from _callRef to _call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests should be consistent and reflect the way we do things in Core. However, testing framework offers too many different ways to do things, and "_callRef" is one of that. Resolves: #89817 Releases: master Change-Id: I44759df255365d0f90e0928f3f5726b66ecf9f3e Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62493 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: Frank Nägler <frank.naegler@typo3.org> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> --- .../Controller/EditDocumentControllerTest.php | 16 ++++++++-- ...stractHierarchicalFilesystemDriverTest.php | 4 +-- .../Unit/Resource/ResourceFactoryTest.php | 9 ++++-- .../Parser/TypoScriptParserTest.php | 20 +++++++++++-- .../Unit/Mvc/Web/Routing/UriBuilderTest.php | 8 ++--- .../Generic/Mapper/DataMapFactoryTest.php | 26 ++++++++-------- .../Generic/Mapper/DataMapperTest.php | 4 +-- .../Generic/Storage/Typo3DbBackendTest.php | 2 +- .../Storage/Typo3DbQueryParserTest.php | 30 +++++++++---------- .../Unit/Property/PropertyMapperTest.php | 28 ++++++++++++----- .../Unit/ViewHelpers/FormViewHelperTest.php | 7 +++-- .../ViewHelpers/Link/PageViewHelperTest.php | 7 +++-- .../TypoScriptFrontendControllerTest.php | 2 +- .../RecordList/DatabaseRecordListTest.php | 2 +- 14 files changed, 108 insertions(+), 57 deletions(-) diff --git a/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php index a7806105317e..8630752d5967 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php @@ -15,7 +15,11 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Controller; * The TYPO3 project - inspiring people to share! */ +use Prophecy\Argument; use TYPO3\CMS\Backend\Controller\EditDocumentController; +use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; /** @@ -43,8 +47,16 @@ class EditDocumentControllerTest extends UnitTestCase 'magic' => 'yes' ]; $result = []; - $mock = $this->getAccessibleMock(EditDocumentController::class, ['dummy'], [], '', false); - $mock->_callRef('parseAdditionalGetParameters', $result, $typoScript); + $moduleTemplate = $this->prophesize(ModuleTemplate::class); + $moduleTemplate->setUiBlock(Argument::any())->willReturn($moduleTemplate->reveal()); + $GLOBALS['LANG'] = $this->prophesize(LanguageService::class)->reveal(); + GeneralUtility::addInstance(ModuleTemplate::class, $moduleTemplate->reveal()); + + $mock = \Closure::bind(static function (EditDocumentController $editDocumentController) use (&$result, $typoScript) { + return $editDocumentController->parseAdditionalGetParameters($result, $typoScript); + }, null, EditDocumentController::class); + $mock(new EditDocumentController()); + self::assertSame($expectedParameters, $result); } diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractHierarchicalFilesystemDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractHierarchicalFilesystemDriverTest.php index da7c410c3b40..2038ef723ee9 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractHierarchicalFilesystemDriverTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/AbstractHierarchicalFilesystemDriverTest.php @@ -41,7 +41,7 @@ class AbstractHierarchicalFilesystemDriverTest extends BaseTestCase */ public function canonicalizeAndCheckFileIdentifierCanonicalizesPath($expectedPath, $fileIdentifier) { - self::assertSame($expectedPath, $this->subject->_callRef('canonicalizeAndCheckFileIdentifier', $fileIdentifier)); + self::assertSame($expectedPath, $this->subject->_call('canonicalizeAndCheckFileIdentifier', $fileIdentifier)); } /** @@ -93,7 +93,7 @@ class AbstractHierarchicalFilesystemDriverTest extends BaseTestCase */ public function canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier($expectedPath, $identifier) { - self::assertSame($expectedPath, $this->subject->_callRef('canonicalizeAndCheckFolderIdentifier', $identifier)); + self::assertSame($expectedPath, $this->subject->_call('canonicalizeAndCheckFolderIdentifier', $identifier)); } /** diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php index dbe34ff370ee..a6832d32eb7a 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource; * The TYPO3 project - inspiring people to share! */ +use Psr\EventDispatcher\EventDispatcherInterface; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -166,8 +167,12 @@ class ResourceFactoryTest extends UnitTestCase */ public function findBestMatchingStorageByLocalPathReturnsDefaultStorageIfNoMatchIsFound(array $storageConfiguration, $path, $expectedStorageId) { - $this->subject->_set('localDriverStorageCache', $storageConfiguration); - self::assertSame($expectedStorageId, $this->subject->_callRef('findBestMatchingStorageByLocalPath', $path)); + $resourceFactory = new ResourceFactory($this->prophesize(EventDispatcherInterface::class)->reveal()); + $mock = \Closure::bind(static function (ResourceFactory $resourceFactory) use (&$path, $storageConfiguration) { + $resourceFactory->localDriverStorageCache = $storageConfiguration; + return $resourceFactory->findBestMatchingStorageByLocalPath($path); + }, null, ResourceFactory::class); + self::assertSame($expectedStorageId, $mock($resourceFactory)); } /** diff --git a/typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php b/typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php index 8954e69e9f35..3b053ec66a86 100644 --- a/typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php +++ b/typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php @@ -1135,7 +1135,15 @@ test.TYPO3Forever.TypoScript = 1 $string = ''; $setup = []; $value = []; - $this->typoScriptParser->_callRef('setVal', $string, $setup, $value); + $typoScriptParser = new TypoScriptParser(); + $mock = \Closure::bind( + static function (TypoScriptParser $typoScriptParser) use ($string, &$setup, $value) { + return $typoScriptParser->setVal($string, $setup, $value); + }, + null, + TypoScriptParser::class + ); + $mock($typoScriptParser); } /** @@ -1146,7 +1154,15 @@ test.TYPO3Forever.TypoScript = 1 $string = ''; $setup = []; $value = ''; - $this->typoScriptParser->_callRef('setVal', $string, $setup, $value); + $typoScriptParser = new TypoScriptParser(); + $mock = \Closure::bind( + static function (TypoScriptParser $typoScriptParser) use ($string, &$setup, $value) { + return $typoScriptParser->setVal($string, $setup, $value); + }, + null, + TypoScriptParser::class + ); + $mock($typoScriptParser); } /** diff --git a/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php b/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php index 5900a08b03b1..336c7ac7fa4e 100644 --- a/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php @@ -875,7 +875,7 @@ class UriBuilderTest extends UnitTestCase $extensionName = 'ExtensionName'; $pluginName = 'PluginName'; $expectedResult = ['controller' => 'SomeController', 'action' => 'someAction', 'foo' => 'bar']; - $actualResult = $this->uriBuilder->_callRef('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); + $actualResult = $this->uriBuilder->_call('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); self::assertEquals($expectedResult, $actualResult); } @@ -890,7 +890,7 @@ class UriBuilderTest extends UnitTestCase $extensionName = 'ExtensionName'; $pluginName = 'PluginName'; $expectedResult = ['action' => 'someAction', 'foo' => 'bar']; - $actualResult = $this->uriBuilder->_callRef('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); + $actualResult = $this->uriBuilder->_call('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); self::assertEquals($expectedResult, $actualResult); } @@ -905,7 +905,7 @@ class UriBuilderTest extends UnitTestCase $extensionName = 'ExtensionName'; $pluginName = 'PluginName'; $expectedResult = ['controller' => 'SomeController', 'foo' => 'bar']; - $actualResult = $this->uriBuilder->_callRef('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); + $actualResult = $this->uriBuilder->_call('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); self::assertEquals($expectedResult, $actualResult); } @@ -920,7 +920,7 @@ class UriBuilderTest extends UnitTestCase $extensionName = 'ExtensionName'; $pluginName = 'PluginName'; $expectedResult = ['foo' => 'bar']; - $actualResult = $this->uriBuilder->_callRef('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); + $actualResult = $this->uriBuilder->_call('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); self::assertEquals($expectedResult, $actualResult); } diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php index b579df923cae..eae656e836da 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php @@ -55,7 +55,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::once())->method('setOneToOneRelation')->willReturn($mockColumnMap); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::never())->method('setManyToManyRelation'); - $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); + $mockDataMapFactory->_call('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); } /** @@ -121,7 +121,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::once())->method('setManyToManyRelation')->willReturn($mockColumnMap); - $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); + $mockDataMapFactory->_call('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); } /** @@ -142,7 +142,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::once())->method('setOneToManyRelation')->willReturn($mockColumnMap); $mockDataMapFactory->expects(self::never())->method('setManyToManyRelation'); - $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); + $mockDataMapFactory->_call('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); } /** @@ -166,7 +166,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::never())->method('setManyToManyRelation'); - $actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $type, $elementType); + $actualColumnMap = $mockDataMapFactory->_call('setRelations', $columnMap, $columnConfiguration, $type, $elementType); self::assertSame($columnMap::RELATION_NONE, $actualColumnMap->getTypeOfRelation()); } @@ -206,7 +206,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::never())->method('setManyToManyRelation'); - $actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $type, $elementType); + $actualColumnMap = $mockDataMapFactory->_call('setRelations', $columnMap, $columnConfiguration, $type, $elementType); self::assertSame($relation, $actualColumnMap->getTypeOfRelation()); } @@ -227,7 +227,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::once())->method('setManyToManyRelation')->willReturn($mockColumnMap); - $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); + $mockDataMapFactory->_call('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); } /** @@ -247,7 +247,7 @@ class DataMapFactoryTest extends UnitTestCase $mockDataMapFactory->expects(self::never())->method('setOneToOneRelation'); $mockDataMapFactory->expects(self::never())->method('setOneToManyRelation'); $mockDataMapFactory->expects(self::once())->method('setManyToManyRelation')->willReturn($mockColumnMap); - $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); + $mockDataMapFactory->_call('setRelations', $mockColumnMap, $columnConfiguration, $type, $elementType); } /** @@ -274,7 +274,7 @@ class DataMapFactoryTest extends UnitTestCase $mockColumnMap->expects(self::never())->method('setRelationTableMatchFields'); $mockColumnMap->expects(self::never())->method('setRelationTableInsertFields'); $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false); - $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); + $mockDataMapFactory->_call('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); } /** @@ -301,7 +301,7 @@ class DataMapFactoryTest extends UnitTestCase $mockColumnMap->expects(self::never())->method('setRelationTableMatchFields'); $mockColumnMap->expects(self::never())->method('setRelationTableInsertFields'); $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false); - $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $rightColumnsDefinition['lefts']); + $mockDataMapFactory->_call('setManyToManyRelation', $mockColumnMap, $rightColumnsDefinition['lefts']); } /** @@ -328,7 +328,7 @@ class DataMapFactoryTest extends UnitTestCase $mockColumnMap->expects(self::never())->method('setRelationTableInsertFields'); $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getColumnsDefinition'], [], '', false); $mockDataMapFactory->expects(self::never())->method('getColumnsDefinition'); - $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); + $mockDataMapFactory->_call('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); } /** @@ -350,7 +350,7 @@ class DataMapFactoryTest extends UnitTestCase $mockColumnMap->expects(self::never())->method('setrelationTablePageIdColumnName'); $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getControlSection'], [], '', false); $mockDataMapFactory->expects(self::once())->method('getControlSection')->with(self::equalTo('tx_myextension_mm'))->willReturn(null); - $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); + $mockDataMapFactory->_call('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); } /** @@ -372,7 +372,7 @@ class DataMapFactoryTest extends UnitTestCase $mockColumnMap->expects(self::once())->method('setrelationTablePageIdColumnName')->with(self::equalTo('pid')); $mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getControlSection'], [], '', false); $mockDataMapFactory->expects(self::once())->method('getControlSection')->with(self::equalTo('tx_myextension_mm'))->willReturn(['ctrl' => ['foo' => 'bar']]); - $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); + $mockDataMapFactory->_call('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']); } /** @@ -420,7 +420,7 @@ class DataMapFactoryTest extends UnitTestCase '', false ); - $accessibleDataMapFactory->_callRef('setFieldEvaluations', $mockColumnMap, $columnDefinition); + $accessibleDataMapFactory->_call('setFieldEvaluations', $mockColumnMap, $columnDefinition); } /** diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php index 5723a1e460f3..7c0ff5574dd9 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php @@ -320,7 +320,7 @@ class DataMapperTest extends UnitTestCase $accessibleDataMapFactory = $this->getAccessibleMock(DataMapper::class, ['dummy'], [], '', false); /** @var $dateTime NULL|\DateTime */ - $dateTime = $accessibleDataMapFactory->_callRef('mapDateTime', $value, $storageFormat); + $dateTime = $accessibleDataMapFactory->_call('mapDateTime', $value, $storageFormat); if ($expectedValue === null) { self::assertNull($dateTime); @@ -341,7 +341,7 @@ class DataMapperTest extends UnitTestCase $storageFormat = 'datetime'; /** @var $dateTime NULL|\DateTime */ - $dateTime = $accessibleDataMapFactory->_callRef('mapDateTime', $date, $storageFormat, $targetType); + $dateTime = $accessibleDataMapFactory->_call('mapDateTime', $date, $storageFormat, $targetType); self::assertInstanceOf($targetType, $dateTime); } diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php index 77b57108b4b2..5b16eabecdb8 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php @@ -128,7 +128,7 @@ class Typo3DbBackendTest extends UnitTestCase $mockTypo3DbBackend->_set('dataMapper', $mockDataMapper); $mockTypo3DbBackend->_set('connectionPool', $connectionPoolProphet->reveal()); $mockTypo3DbBackend->_set('environmentService', $environmentServiceProphet->reveal()); - $result = $mockTypo3DbBackend->_callRef('getUidOfAlreadyPersistedValueObject', $mockValueObject); + $result = $mockTypo3DbBackend->getUidOfAlreadyPersistedValueObject($mockValueObject); self::assertSame($expectedUid, $result); } } diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php index 8fad42a68847..c5449fe18751 100644 --- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php @@ -353,7 +353,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $sql = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = $table . '.sys_language_uid IN (0, -1)'; self::assertSame($expectedSql, $sql); } @@ -375,7 +375,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $sql = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $result = $table . '.sys_language_uid IN (1, -1)'; self::assertSame($result, $sql); } @@ -393,7 +393,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $sql = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = $table . '.sys_language_uid IN (0, -1)'; self::assertSame($expectedSql, $sql); } @@ -413,7 +413,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $sql = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = $table . '.sys_language_uid IN (0, -1)'; self::assertSame($expectedSql, $sql); } @@ -432,7 +432,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $sql = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = $table . '.sys_language_uid IN (2, -1)'; self::assertSame($expectedSql, $sql); } @@ -455,7 +455,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $compositeExpression = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $compositeExpression = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = '(' . $table . '.sys_language_uid = -1) OR ((' . $table . '.sys_language_uid = 2) AND (' . $table . '.l10n_parent IN (SELECT ' . $table . '_dl.uid FROM ' . $table . ' ' . $table . '_dl WHERE (' . $table . '_dl.l10n_parent = 0) AND (' . $table . '_dl.sys_language_uid = 0)))) OR ((' . $table . '.sys_language_uid = 0) AND (' . $table . '.uid NOT IN (SELECT ' . $table . '_to.l10n_parent FROM ' . $table . ' ' . $table . '_dl, ' . $table . ' ' . $table . '_to WHERE (' . $table . '_to.l10n_parent > 0) AND (' . $table . '_to.sys_language_uid = 2))))'; self::assertSame($expectedSql, $compositeExpression->__toString()); } @@ -476,7 +476,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderProphetWithQueryBuilderForSubselect(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $compositeExpression= $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $compositeExpression= $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = '(' . $table . '.sys_language_uid = -1) OR ((' . $table . '.sys_language_uid = 2) AND (' . $table . '.l10n_parent IN (SELECT ' . $table . '_dl.uid FROM ' . $table . ' ' . $table . '_dl WHERE (' . $table . '_dl.l10n_parent = 0) AND (' . $table . '_dl.sys_language_uid = 0) AND (' . $table . '_dl.deleted = 0)))) OR ((' . $table . '.sys_language_uid = 0) AND (' . $table . '.uid NOT IN (SELECT ' . $table . '_to.l10n_parent FROM ' . $table . ' ' . $table . '_dl, ' . $table . ' ' . $table . '_to WHERE (' . $table . '_to.l10n_parent > 0) AND (' . $table . '_to.sys_language_uid = 2) AND ((' . $table . '_dl.deleted = 0) AND (' . $table . '_to.deleted = 0)))))'; self::assertSame($expectedSql, $compositeExpression->__toString()); } @@ -499,7 +499,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $queryBuilderProphet = $this->getQueryBuilderProphetWithQueryBuilderForSubselect(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $compositeExpression = $mockTypo3DbQueryParser->_callRef('getLanguageStatement', $table, $table, $querySettings); + $compositeExpression = $mockTypo3DbQueryParser->_call('getLanguageStatement', $table, $table, $querySettings); $expectedSql = '(' . $table . '.sys_language_uid = -1) OR ((' . $table . '.sys_language_uid = 2) AND (' . $table . '.l10n_parent IN (SELECT ' . $table . '_dl.uid FROM ' . $table . ' ' . $table . '_dl WHERE (' . $table . '_dl.l10n_parent = 0) AND (' . $table . '_dl.sys_language_uid = 0) AND (' . $table . '_dl.deleted = 0)))) OR ((' . $table . '.sys_language_uid = 0) AND (' . $table . '.uid NOT IN (SELECT ' . $table . '_to.l10n_parent FROM ' . $table . ' ' . $table . '_dl, ' . $table . ' ' . $table . '_to WHERE (' . $table . '_to.l10n_parent > 0) AND (' . $table . '_to.sys_language_uid = 2) AND ((' . $table . '_dl.deleted = 0) AND (' . $table . '_to.deleted = 0)))))'; self::assertSame($expectedSql, $compositeExpression->__toString()); } @@ -527,7 +527,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $mockTypo3DbQueryParser->_set('dataMapper', $mockDataMapper); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $mockTypo3DbQueryParser->_callRef('parseOrderings', $orderings, $mockSource); + $mockTypo3DbQueryParser->_call('parseOrderings', $orderings, $mockSource); } /** @@ -552,7 +552,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $mockTypo3DbQueryParser->_set('dataMapper', $mockDataMapper); - $mockTypo3DbQueryParser->_callRef('parseOrderings', $orderings, $mockSource); + $mockTypo3DbQueryParser->_call('parseOrderings', $orderings, $mockSource); } /** @@ -586,7 +586,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $queryBuilder->expects(self::at(1))->method('addOrderBy')->with('tx_myext_tablename.converted_fieldname', 'DESC'); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilder); - $mockTypo3DbQueryParser->_callRef('parseOrderings', $orderings, $mockSource); + $mockTypo3DbQueryParser->_call('parseOrderings', $orderings, $mockSource); } public function providerForVisibilityConstraintStatement() @@ -653,7 +653,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $mockTypo3DbQueryParser->_set('environmentService', $mockEnvironmentService); - $resultSql = $mockTypo3DbQueryParser->_callRef('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); + $resultSql = $mockTypo3DbQueryParser->_call('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); self::assertSame($expectedSql, $resultSql); unset($GLOBALS['TCA'][$tableName]); } @@ -717,7 +717,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $mockTypo3DbQueryParser->_set('environmentService', $mockEnvironmentService); - $actualSql = $mockTypo3DbQueryParser->_callRef('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); + $actualSql = $mockTypo3DbQueryParser->_call('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); self::assertSame($expectedSql, $actualSql); unset($GLOBALS['TCA'][$tableName]); } @@ -752,7 +752,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $mockTypo3DbQueryParser->_set('environmentService', $mockEnvironmentService); - $mockTypo3DbQueryParser->_callRef('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); + $mockTypo3DbQueryParser->_call('getVisibilityConstraintStatement', $mockQuerySettings, $tableName, $tableName); unset($GLOBALS['TCA'][$tableName]); } @@ -804,7 +804,7 @@ class Typo3DbQueryParserTest extends UnitTestCase $mockTypo3DbQueryParser = $this->getAccessibleMock(Typo3DbQueryParser::class, ['dummy'], [], '', false); $queryBuilderProphet = $this->getQueryBuilderWithExpressionBuilderProphet(); $mockTypo3DbQueryParser->_set('queryBuilder', $queryBuilderProphet->reveal()); - $sql = $mockTypo3DbQueryParser->_callRef('getPageIdStatement', $table, $table, $storagePageIds); + $sql = $mockTypo3DbQueryParser->_call('getPageIdStatement', $table, $table, $storagePageIds); self::assertSame($expectedSql, $sql); } diff --git a/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php b/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php index 70e7a7f6f27d..bde1d75c2f30 100644 --- a/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php @@ -14,7 +14,9 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Property; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Property\Exception\InvalidSourceException; +use TYPO3\CMS\Extbase\Property\PropertyMapper; use TYPO3\CMS\Extbase\Tests\Unit\Property\Fixtures\DataProviderOneInterface; use TYPO3\CMS\Extbase\Tests\Unit\Property\Fixtures\DataProviderThree; use TYPO3\CMS\Extbase\Tests\Unit\Property\Fixtures\DataProviderThreeInterface; @@ -369,11 +371,16 @@ class PropertyMapperTest extends UnitTestCase */ public function doMappingReturnsSourceUnchangedIfAlreadyConverted() { - $source = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); - $targetType = \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class; + $source = new ObjectStorage(); + $targetType = ObjectStorage::class; $propertyPath = ''; - $propertyMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Property\PropertyMapper::class, ['dummy']); - self::assertSame($source, $propertyMapper->_callRef('doMapping', $source, $targetType, $this->mockConfiguration, $propertyPath)); + $propertyMapper = new PropertyMapper(); + $mockConf = $this->mockConfiguration; + $mock = \Closure::bind(static function (PropertyMapper $propertyMapper) use ($source, $targetType, $mockConf, &$propertyPath) { + return $propertyMapper->doMapping($source, $targetType, $mockConf, $propertyPath); + }, null, PropertyMapper::class); + + self::assertSame($source, $mock($propertyMapper)); } /** @@ -381,11 +388,16 @@ class PropertyMapperTest extends UnitTestCase */ public function doMappingReturnsSourceUnchangedIfAlreadyConvertedToCompositeType() { - $source = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); - $targetType = \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class . '<SomeEntity>'; + $source = new ObjectStorage(); + $targetType = ObjectStorage::class . '<SomeEntity>'; $propertyPath = ''; - $propertyMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Property\PropertyMapper::class, ['dummy']); - self::assertSame($source, $propertyMapper->_callRef('doMapping', $source, $targetType, $this->mockConfiguration, $propertyPath)); + $propertyMapper = new PropertyMapper(); + $mockConf = $this->mockConfiguration; + $mock = \Closure::bind(static function (PropertyMapper $propertyMapper) use ($source, $targetType, $mockConf, &$propertyPath) { + return $propertyMapper->doMapping($source, $targetType, $mockConf, $propertyPath); + }, null, PropertyMapper::class); + + self::assertSame($source, $mock($propertyMapper)); } /** diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php index 3c92b536b1ed..9b6917c52137 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php @@ -367,9 +367,12 @@ class FormViewHelperTest extends ViewHelperBaseTestcase */ public function postProcessUriArgumentsForRequestHashWorks($arguments, $expectedResults) { - $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['dummy'], [], '', false); + $formViewHelper = new FormViewHelper(); $results = []; - $viewHelper->_callRef('postProcessUriArgumentsForRequestHash', $arguments, $results); + $mock = \Closure::bind(static function (FormViewHelper $formViewHelper) use ($arguments, &$results) { + return $formViewHelper->postProcessUriArgumentsForRequestHash($arguments, $results); + }, null, FormViewHelper::class); + $mock($formViewHelper); self::assertEquals($expectedResults, $results); } } diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/PageViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/PageViewHelperTest.php index 65a61fb5dc76..d790903c1d25 100644 --- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/PageViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/PageViewHelperTest.php @@ -16,8 +16,8 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Link; */ use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; +use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; use TYPO3\CMS\Fluid\ViewHelpers\Link\PageViewHelper; -use TYPO3\TestingFramework\Fluid\Unit\Core\Rendering\RenderingContextFixture; use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase; use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder; @@ -61,7 +61,10 @@ class PageViewHelperTest extends ViewHelperBaseTestcase $this->controllerContext->expects(self::any())->method('getUriBuilder')->willReturn($this->uriBuilder); $this->controllerContext->expects(self::any())->method('getRequest')->willReturn($this->request->reveal()); $this->arguments = []; - $this->renderingContext = $this->getAccessibleMock(RenderingContextFixture::class, ['getControllerContext']); + $this->renderingContext = $this->getMockBuilder(RenderingContext::class) + ->onlyMethods(['getControllerContext']) + ->disableOriginalConstructor() + ->getMock(); $this->renderingContext->expects(self::any())->method('getControllerContext')->willReturn($this->controllerContext); // until here diff --git a/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php b/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php index 30128ff59110..e43f61e45589 100644 --- a/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php @@ -263,7 +263,7 @@ class TypoScriptFrontendControllerTest extends UnitTestCase */ public function splitLinkVarsStringSplitsStringByComma($string, $expected) { - self::assertEquals($expected, $this->subject->_callRef('splitLinkVarsString', $string)); + self::assertEquals($expected, $this->subject->_call('splitLinkVarsString', $string)); } /** diff --git a/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php b/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php index 40936fa38e71..efc4932279e6 100644 --- a/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php +++ b/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php @@ -226,6 +226,6 @@ class DatabaseRecordListTest extends UnitTestCase */ public function getVisibleColumns(array $tableTCA, string $type, string $expected) { - self::assertSame($expected, $this->subject->_callRef('getVisibleColumns', $tableTCA, $type)); + self::assertSame($expected, $this->subject->_call('getVisibleColumns', $tableTCA, $type)); } } -- GitLab