From 50153d664897b7bf235a2be22305aa211fda0e05 Mon Sep 17 00:00:00 2001 From: Wouter Wolters <typo3@wouterwolters.nl> Date: Sun, 15 Aug 2021 19:20:48 +0200 Subject: [PATCH] [TASK] Use $this for expectException* methods of PHPunit The methods are now called statically but are not statically defined. Use $this instead. Resolves: #94894 Releases: master Change-Id: I2b1d5efc21af49ce447368440cbcbe5fabc94ffe Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70601 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> --- .../Tests/Functional/Routing/RouterTest.php | 4 +- .../IO/PharStreamWrapperInterceptorTest.php | 20 ++++---- .../Imaging/ImageMagickFileTest.php | 8 ++-- .../Utility/RootlineUtilityTest.php | 4 +- .../Unit/Pagination/ArrayPaginatorTest.php | 2 +- .../Functional/Mvc/Web/RequestBuilderTest.php | 48 +++++++++---------- .../Pagination/QueryResultPaginatorTest.php | 2 +- .../Property/PropertyMapperTest.php | 48 +++++++++---------- .../TypeConverter/DateTimeConverterTest.php | 18 +++---- .../TypeConverter/ObjectConverterTest.php | 48 +++++++++---------- .../PersistentObjectConverterTest.php | 30 ++++++------ .../ClassSchema/MethodParameterTest.php | 2 +- 12 files changed, 117 insertions(+), 117 deletions(-) diff --git a/typo3/sysext/backend/Tests/Functional/Routing/RouterTest.php b/typo3/sysext/backend/Tests/Functional/Routing/RouterTest.php index c86926042873..672a865dac76 100644 --- a/typo3/sysext/backend/Tests/Functional/Routing/RouterTest.php +++ b/typo3/sysext/backend/Tests/Functional/Routing/RouterTest.php @@ -54,7 +54,7 @@ class RouterTest extends FunctionalTestCase $subject = GeneralUtility::makeInstance(Router::class); $request = new ServerRequest('https://example.com/this-path/does-not-exist', 'GET'); $request = $request->withAttribute('normalizedParams', NormalizedParams::createFromRequest($request)); - self::expectException(ResourceNotFoundException::class); + $this->expectException(ResourceNotFoundException::class); $subject->matchRequest($request); } @@ -66,7 +66,7 @@ class RouterTest extends FunctionalTestCase $subject = GeneralUtility::makeInstance(Router::class); $request = new ServerRequest('https://example.com/login/password-reset/initiate-reset', 'GET'); $request = $request->withAttribute('normalizedParams', NormalizedParams::createFromRequest($request)); - self::expectException(MethodNotAllowedException::class); + $this->expectException(MethodNotAllowedException::class); $subject->matchRequest($request); } diff --git a/typo3/sysext/core/Tests/Functional/IO/PharStreamWrapperInterceptorTest.php b/typo3/sysext/core/Tests/Functional/IO/PharStreamWrapperInterceptorTest.php index 28507fca0d63..b1eb41c69daa 100644 --- a/typo3/sysext/core/Tests/Functional/IO/PharStreamWrapperInterceptorTest.php +++ b/typo3/sysext/core/Tests/Functional/IO/PharStreamWrapperInterceptorTest.php @@ -149,8 +149,8 @@ class PharStreamWrapperInterceptorTest extends FunctionalTestCase */ public function directoryActionDeniesInvocation(string $path) { - self::expectException(Exception::class); - self::expectExceptionCode(1539625084); + $this->expectException(Exception::class); + $this->expectExceptionCode(1539625084); $path = $this->instancePath . '/' . $path; opendir('phar://' . $path); @@ -286,8 +286,8 @@ class PharStreamWrapperInterceptorTest extends FunctionalTestCase */ public function urlStatDeniesInvocation(string $functionName, string $path) { - self::expectException(Exception::class); - self::expectExceptionCode(1539625084); + $this->expectException(Exception::class); + $this->expectExceptionCode(1539625084); $path = $this->instancePath . '/' . $path; $functionName('phar://' . $path); @@ -370,8 +370,8 @@ class PharStreamWrapperInterceptorTest extends FunctionalTestCase */ public function streamOpenDeniesInvocationForFileOpen() { - self::expectException(Exception::class); - self::expectExceptionCode(1539625084); + $this->expectException(Exception::class); + $this->expectExceptionCode(1539625084); $allowedPath = $this->instancePath . '/fileadmin/bundle.phar'; fopen('phar://' . $allowedPath . '/Resources/content.txt', 'r'); @@ -382,8 +382,8 @@ class PharStreamWrapperInterceptorTest extends FunctionalTestCase */ public function streamOpenDeniesInvocationForFileGetContents() { - self::expectException(Exception::class); - self::expectExceptionCode(1539625084); + $this->expectException(Exception::class); + $this->expectExceptionCode(1539625084); $allowedPath = $this->instancePath . '/fileadmin/bundle.phar'; file_get_contents('phar://' . $allowedPath . '/Resources/content.txt'); @@ -403,8 +403,8 @@ class PharStreamWrapperInterceptorTest extends FunctionalTestCase */ public function streamOpenDeniesInvocationForInclude(string $path) { - self::expectException(Exception::class); - self::expectExceptionCode(1539625084); + $this->expectException(Exception::class); + $this->expectExceptionCode(1539625084); $allowedPath = $this->instancePath . '/' . $path; include('phar://' . $allowedPath . '/Classes/Domain/Model/DemoModel.php'); diff --git a/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php b/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php index 3fac37002d10..53b4d4e26fc5 100644 --- a/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php +++ b/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php @@ -270,8 +270,8 @@ class ImageMagickFileTest extends FunctionalTestCase */ public function fileStatementIsDenied(string $fileName, string $mimeType = null) { - self::expectException(Exception::class); - self::expectExceptionCode(1550060977); + $this->expectException(Exception::class); + $this->expectExceptionCode(1550060977); if ($mimeType !== null) { $this->simulateNextFileInfoInvocation($mimeType); @@ -303,8 +303,8 @@ class ImageMagickFileTest extends FunctionalTestCase $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']['ps'] = 'image/x-see-no-evil'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']['eps'] = 'image/x-see-no-evil'; - self::expectException(Exception::class); - self::expectExceptionCode(1550060977); + $this->expectException(Exception::class); + $this->expectExceptionCode(1550060977); $filePath = sprintf('%s/%s', $this->directory->url(), $fileName); ImageMagickFile::fromFilePath($filePath, null); diff --git a/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php b/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php index 6a7587480af2..a2ece47c9fd7 100644 --- a/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php +++ b/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php @@ -314,8 +314,8 @@ class RootlineUtilityTest extends FunctionalTestCase */ public function rootlineFailsForDeletedParentPageInWorkspace() { - self::expectException(PageNotFoundException::class); - self::expectExceptionCode(1343464101); + $this->expectException(PageNotFoundException::class); + $this->expectExceptionCode(1343464101); $context = GeneralUtility::makeInstance(Context::class); $context->setAspect('workspace', new WorkspaceAspect(2)); $subject = new RootlineUtility(1310, '', $context); diff --git a/typo3/sysext/core/Tests/Unit/Pagination/ArrayPaginatorTest.php b/typo3/sysext/core/Tests/Unit/Pagination/ArrayPaginatorTest.php index fc8e0baef069..b82c8b526aa6 100644 --- a/typo3/sysext/core/Tests/Unit/Pagination/ArrayPaginatorTest.php +++ b/typo3/sysext/core/Tests/Unit/Pagination/ArrayPaginatorTest.php @@ -112,7 +112,7 @@ class ArrayPaginatorTest extends UnitTestCase */ public function withCurrentPageNumberThrowsInvalidArgumentExceptionIfCurrentPageIsLowerThanOne() { - static::expectExceptionCode(1573047338); + $this->expectExceptionCode(1573047338); $paginator = new ArrayPaginator( $this->fixture, diff --git a/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php b/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php index a5cd6c6dad55..192de421058d 100644 --- a/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php @@ -133,9 +133,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function loadDefaultValuesThrowsExceptionIfExtensionNameIsNotProperlyConfigured() { - static::expectException(Exception::class); - static::expectExceptionCode(1289843275); - static::expectExceptionMessage('"extensionName" is not properly configured. Request can\'t be dispatched!'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1289843275); + $this->expectExceptionMessage('"extensionName" is not properly configured. Request can\'t be dispatched!'); $mainRequest = $this->prepareServerRequest('https://example.com/'); $requestBuilder = $this->getContainer()->get(RequestBuilder::class); @@ -147,9 +147,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function loadDefaultValuesThrowsExceptionIfPluginNameIsNotProperlyConfigured() { - static::expectException(Exception::class); - static::expectExceptionCode(1289843277); - static::expectExceptionMessage('"pluginName" is not properly configured. Request can\'t be dispatched!'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1289843277); + $this->expectExceptionMessage('"pluginName" is not properly configured. Request can\'t be dispatched!'); $configurationManager = $this->getContainer()->get(ConfigurationManager::class); $configurationManager->setConfiguration(['extensionName' => 'blog_example']); @@ -275,9 +275,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveControllerClassNameThrowsInvalidControllerNameExceptionIfNonExistentControllerIsSetViaGetParameter() { - static::expectException(InvalidControllerNameException::class); - static::expectExceptionCode(1313855173); - static::expectExceptionMessage('The controller "NonExistentController" is not allowed by plugin "blog". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); + $this->expectException(InvalidControllerNameException::class); + $this->expectExceptionCode(1313855173); + $this->expectExceptionMessage('The controller "NonExistentController" is not allowed by plugin "blog". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController'; @@ -310,9 +310,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveControllerClassNameThrowsPageNotFoundException() { - static::expectException(PageNotFoundException::class); - static::expectExceptionCode(1313857897); - static::expectExceptionMessage('The requested resource was not found'); + $this->expectException(PageNotFoundException::class); + $this->expectExceptionCode(1313857897); + $this->expectExceptionMessage('The requested resource was not found'); $extensionName = 'blog_example'; $pluginName = 'blog'; @@ -344,9 +344,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveControllerClassNameThrowsAnExceptionIfTheDefaultControllerCannotBeDetermined() { - static::expectException(Exception::class); - static::expectExceptionCode(1316104317); - static::expectExceptionMessage('The default controller for extension "blog_example" and plugin "blog" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1316104317); + $this->expectExceptionMessage('The default controller for extension "blog_example" and plugin "blog" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); $extensionName = 'blog_example'; $pluginName = 'blog'; @@ -442,9 +442,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveActionNameThrowsInvalidActionNameExceptionIfNonExistentActionIsSetViaGetParameter() { - static::expectException(InvalidActionNameException::class); - static::expectExceptionCode(1313855175); - static::expectExceptionMessage('The action "NonExistentAction" (controller "ExtbaseTeam\BlogExample\Controller\BlogController") is not allowed by this plugin / module. Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php / TYPO3\CMS\Extbase\Utility\ExtensionUtility::configureModule() in your ext_tables.php.'); + $this->expectException(InvalidActionNameException::class); + $this->expectExceptionCode(1313855175); + $this->expectExceptionMessage('The action "NonExistentAction" (controller "ExtbaseTeam\BlogExample\Controller\BlogController") is not allowed by this plugin / module. Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php / TYPO3\CMS\Extbase\Utility\ExtensionUtility::configureModule() in your ext_tables.php.'); $extensionName = 'blog_example'; $pluginName = 'blog'; @@ -475,9 +475,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveActionNameThrowsPageNotFoundException() { - static::expectException(PageNotFoundException::class); - static::expectExceptionCode(1313857898); - static::expectExceptionMessage('The requested resource was not found'); + $this->expectException(PageNotFoundException::class); + $this->expectExceptionCode(1313857898); + $this->expectExceptionMessage('The requested resource was not found'); $extensionName = 'blog_example'; $pluginName = 'blog'; @@ -576,9 +576,9 @@ class RequestBuilderTest extends FunctionalTestCase */ public function resolveActionNameThrowsAnExceptionIfTheDefaultActionCannotBeDetermined() { - static::expectException(Exception::class); - static::expectExceptionCode(1295479651); - static::expectExceptionMessage('The default action can not be determined for controller "ExtbaseTeam\BlogExample\Controller\BlogController". Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1295479651); + $this->expectExceptionMessage('The default action can not be determined for controller "ExtbaseTeam\BlogExample\Controller\BlogController". Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.'); $extensionName = 'blog_example'; $pluginName = 'blog'; diff --git a/typo3/sysext/extbase/Tests/Functional/Pagination/QueryResultPaginatorTest.php b/typo3/sysext/extbase/Tests/Functional/Pagination/QueryResultPaginatorTest.php index 577b8e66fb84..ffc5b5ac6957 100644 --- a/typo3/sysext/extbase/Tests/Functional/Pagination/QueryResultPaginatorTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Pagination/QueryResultPaginatorTest.php @@ -120,7 +120,7 @@ class QueryResultPaginatorTest extends FunctionalTestCase */ public function withCurrentPageNumberThrowsInvalidArgumentExceptionIfCurrentPageIsLowerThanOne() { - static::expectExceptionCode(1573047338); + $this->expectExceptionCode(1573047338); $paginator = new QueryResultPaginator( $this->postRepository->findAll(), diff --git a/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php b/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php index 31b5bcbf8e05..4d51f4095700 100644 --- a/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php @@ -42,7 +42,7 @@ class PropertyMapperTest extends FunctionalTestCase */ public function initializeObjectThrowsDuplicateTypeConverterException() { - static::expectExceptionCode(1297951378); + $this->expectExceptionCode(1297951378); $class = new class() extends ArrayConverter { }; @@ -76,8 +76,8 @@ class PropertyMapperTest extends FunctionalTestCase */ public function convertThrowsATargetNotFoundException() { - static::expectException(TargetNotFoundException::class); - static::expectExceptionCode(1297933823); + $this->expectException(TargetNotFoundException::class); + $this->expectExceptionCode(1297933823); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapper->convert(9999, BackendUser::class); @@ -88,9 +88,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function convertThrowsAnExceptionIfNoTypeConverterCanBeFoundForTheConversionOfSimpleTypes() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": No converter found which can be used to convert from "integer" to "boolean"'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": No converter found which can be used to convert from "integer" to "boolean"'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapper->convert(9999, 'boolean'); @@ -101,9 +101,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function convertThrowsAnExceptionIfTargetTypeIsNotAString() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": The target type was no string, but of type "NULL"'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": The target type was no string, but of type "NULL"'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapper->convert(9999, null); @@ -123,9 +123,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function convertThrowsAnExceptionIfTargetTypeIsANonExistingClass() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Could not find a suitable type converter for "NonExistingClass" because no such class or interface exists.'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Could not find a suitable type converter for "NonExistingClass" because no such class or interface exists.'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapper->convert(1, 'NonExistingClass'); @@ -136,9 +136,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function convertThrowsAnExceptionIfAtLeastTwoConvertersAreRegisteredThatHandleTheConversionToTheSameInterface() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('There exist at least two converters which handle the conversion to an interface with priority "10"'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('There exist at least two converters which handle the conversion to an interface with priority "10"'); $converterOne = new class() extends AbstractTypeConverter { protected $priority = 10; @@ -220,9 +220,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function determineSourceTypeThrowsInvalidSourceExceptionForNonSupportedTypes() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('The source is not of type string, array, float, integer or boolean, but of type "object"'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('The source is not of type string, array, float, integer or boolean, but of type "object"'); $generator = function () { return 'string'; @@ -237,9 +237,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function findFirstEligibleTypeConverterInObjectHierarchyReturnsNullIfNoTypeConvertersExistForTheSourceType() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": No converter found which can be used to convert from "integer" to "TYPO3\CMS\Extbase\Tests\Functional\Property\Fixtures\Cat"'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": No converter found which can be used to convert from "integer" to "TYPO3\CMS\Extbase\Tests\Functional\Property\Fixtures\Cat"'); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = []; @@ -375,9 +375,9 @@ class PropertyMapperTest extends FunctionalTestCase */ public function allowAllPropertiesExceptConfiguration() { - static::expectException(\Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('It is not allowed to map property "color". You need to use $propertyMappingConfiguration->allowProperties(\'color\') to enable mapping of this property.'); + $this->expectException(\Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('It is not allowed to map property "color". You need to use $propertyMappingConfiguration->allowProperties(\'color\') to enable mapping of this property.'); $source = [ 'color' => 'black', diff --git a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/DateTimeConverterTest.php b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/DateTimeConverterTest.php index 587c70e49c7f..0c7b93da2749 100644 --- a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/DateTimeConverterTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/DateTimeConverterTest.php @@ -102,9 +102,9 @@ class DateTimeConverterTest extends FunctionalTestCase */ public function convertThrowsInvalidPropertyMappingConfigurationExceptionIfDateFormatIsNotAString() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": CONFIGURATION_DATE_FORMAT must be of type string, "array" given'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": CONFIGURATION_DATE_FORMAT must be of type string, "array" given'); $propertyMapperConfiguration = new PropertyMappingConfiguration(); $propertyMapperConfiguration->setTypeConverterOption( @@ -322,9 +322,9 @@ class DateTimeConverterTest extends FunctionalTestCase */ public function convertFromThrowsTypeConverterExceptionIfSourceIsAnInvalidArraySource() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Could not convert the given source into a DateTime object because it was not an array with a valid date as a string'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Could not convert the given source into a DateTime object because it was not an array with a valid date as a string'); $this->getContainer()->get(PropertyMapper::class)->convert([], \DateTime::class); } @@ -334,9 +334,9 @@ class DateTimeConverterTest extends FunctionalTestCase */ public function convertFromThrowsTypeConverterExceptionIfGivenDateTimeZoneIsInvalid() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": The specified timezone "foo" is invalid.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": The specified timezone "foo" is invalid.'); $propertyMapperConfiguration = new PropertyMappingConfiguration(); $propertyMapperConfiguration->setTypeConverterOption( diff --git a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/ObjectConverterTest.php b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/ObjectConverterTest.php index 490cbcc5a6c4..29dd31e9e3c9 100644 --- a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/ObjectConverterTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/ObjectConverterTest.php @@ -186,9 +186,9 @@ class ObjectConverterTest extends FunctionalTestCase $className = get_class($class); $propertyName = 'name'; - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor arguments as said class does not have a constructor defined.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor arguments as said class does not have a constructor defined.'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapperConfiguration = new PropertyMappingConfiguration(); @@ -215,9 +215,9 @@ class ObjectConverterTest extends FunctionalTestCase $className = get_class($class); $propertyName = 'name'; - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor arguments as the constructor of said class does not have a parameter with property name "' . $propertyName . '".'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor arguments as the constructor of said class does not have a parameter with property name "' . $propertyName . '".'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapperConfiguration = new PropertyMappingConfiguration(); @@ -244,9 +244,9 @@ class ObjectConverterTest extends FunctionalTestCase $className = get_class($class); $propertyName = 'name'; - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor argument "' . $propertyName . '". This usually happens if the argument misses a type hint.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Type of child property "' . $propertyName . '" of class "' . $className . '" could not be derived from constructor argument "' . $propertyName . '". This usually happens if the argument misses a type hint.'); $propertyMapper = $this->getContainer()->get(PropertyMapper::class); $propertyMapperConfiguration = new PropertyMappingConfiguration(); @@ -264,9 +264,9 @@ class ObjectConverterTest extends FunctionalTestCase */ public function getTypeOfChildPropertyThrowsInvalidTargetExceptionIfPropertySetterDoesNotDefineAType() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Setter for property "name" had no type hint or documentation in target object of type "'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Setter for property "name" had no type hint or documentation in target object of type "'); $class = new class() { public function setName($name) @@ -290,9 +290,9 @@ class ObjectConverterTest extends FunctionalTestCase */ public function convertFromThrowsInvalidTargetExceptionIfPropertiesCannotBeSet() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Property "name" having a value of type "string" could not be set in target object of type "'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Property "name" having a value of type "string" could not be set in target object of type "'); $class = new class() { private $name; @@ -346,9 +346,9 @@ class ObjectConverterTest extends FunctionalTestCase */ public function buildObjectThrowsInvalidTargetExceptionIfMandatoryConstructorArgumentIsMissing() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Missing constructor argument "color" for object of type "'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Missing constructor argument "color" for object of type "'); $class = new class('', '') { public $name; @@ -371,9 +371,9 @@ class ObjectConverterTest extends FunctionalTestCase */ public function getTargetTypeForSourceThrowsInvalidPropertyMappingConfigurationExceptionIfTargetTypeOverridingIsNotAllowed() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.'); $class = new class() { }; @@ -389,9 +389,9 @@ class ObjectConverterTest extends FunctionalTestCase */ public function getTargetTypeForSourceThrowsInvalidDataTypeExceptionIfOverriddenTargetTypeIsNotASubtypeOfOriginalTargetType() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": The given type "TYPO3\CMS\Extbase\Tests\Functional\Property\Fixtures\Animal" is not a subtype of "'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": The given type "TYPO3\CMS\Extbase\Tests\Functional\Property\Fixtures\Animal" is not a subtype of "'); $class = new class() { }; diff --git a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/PersistentObjectConverterTest.php b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/PersistentObjectConverterTest.php index bf56a1f5f3d2..2521a00ca715 100644 --- a/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/PersistentObjectConverterTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Property/TypeConverter/PersistentObjectConverterTest.php @@ -52,9 +52,9 @@ class PersistentObjectConverterTest extends FunctionalTestCase */ public function fetchObjectFromPersistenceThrowsInvalidSourceExceptionIfSourceIANonNumericString() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": The identity property "foo" is no UID.'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": The identity property "foo" is no UID.'); $this->getContainer()->get(PropertyMapper::class)->convert('foo', BackendUser::class); } @@ -64,9 +64,9 @@ class PersistentObjectConverterTest extends FunctionalTestCase */ public function fetchObjectFromPersistenceThrowsTargetNotFoundExceptionIfObjectIsNotToBeFoundInThePersistence() { - static::expectException(TargetNotFoundException::class); - static::expectExceptionCode(1297933823); - static::expectExceptionMessage('Object of type TYPO3\CMS\Beuser\Domain\Model\BackendUser with identity "2" not found.'); + $this->expectException(TargetNotFoundException::class); + $this->expectExceptionCode(1297933823); + $this->expectExceptionMessage('Object of type TYPO3\CMS\Beuser\Domain\Model\BackendUser with identity "2" not found.'); $this->getContainer()->get(PropertyMapper::class)->convert(2, BackendUser::class); } @@ -128,9 +128,9 @@ class PersistentObjectConverterTest extends FunctionalTestCase */ public function handleArrayDataThrowsInvalidPropertyMappingConfigurationExceptionIfCreationOfObjectsIsNotAllowed() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE'); $propertyMapperConfiguration = new PropertyMappingConfiguration(); $propertyMapperConfiguration->setTypeConverterOption( @@ -165,9 +165,9 @@ class PersistentObjectConverterTest extends FunctionalTestCase */ public function getTypeOfChildPropertyThrowsInvalidTargetExceptionIfPropertyIsNonExistant() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Property "nonExistant" was not found in target object of type "TYPO3\CMS\Beuser\Domain\Model\BackendUser".'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Property "nonExistant" was not found in target object of type "TYPO3\CMS\Beuser\Domain\Model\BackendUser".'); $this->getContainer()->get(PropertyMapper::class)->convert(['nonExistant' => 'johndoe'], BackendUser::class); } @@ -177,9 +177,9 @@ class PersistentObjectConverterTest extends FunctionalTestCase */ public function convertFromThrowsInvalidTargetExceptionIfSourceContainsANonSettableProperty() { - static::expectException(Exception::class); - static::expectExceptionCode(1297759968); - static::expectExceptionMessage('Exception while property mapping at property path "": Property "uid" having a value of type "integer" could not be set in target object of type "TYPO3\CMS\Beuser\Domain\Model\BackendUser"'); + $this->expectException(Exception::class); + $this->expectExceptionCode(1297759968); + $this->expectExceptionMessage('Exception while property mapping at property path "": Property "uid" having a value of type "integer" could not be set in target object of type "TYPO3\CMS\Beuser\Domain\Model\BackendUser"'); $this->getContainer()->get(PropertyMapper::class)->convert(['uid' => 7], BackendUser::class); } diff --git a/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchema/MethodParameterTest.php b/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchema/MethodParameterTest.php index 3480f049ac57..be886468dca4 100644 --- a/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchema/MethodParameterTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchema/MethodParameterTest.php @@ -100,7 +100,7 @@ class MethodParameterTest extends UnitTestCase self::assertTrue($classSchemaMethod->getParameter('foo')->ignoreValidation()); self::assertTrue($classSchemaMethod->getParameter('bar')->ignoreValidation()); - static::expectException(NoSuchMethodParameterException::class); + $this->expectException(NoSuchMethodParameterException::class); $classSchemaMethod->getParameter('baz')->ignoreValidation(); } -- GitLab