[TASK] Make tests PHPUnit v9 compatible 97/63797/3
authorBenni Mack <benni@typo3.org>
Thu, 19 Mar 2020 13:43:13 +0000 (14:43 +0100)
committerBenni Mack <benni@typo3.org>
Thu, 19 Mar 2020 15:00:17 +0000 (16:00 +0100)
This change modifies "->expectExceptionMessageRegExp" which is
not available anymore in PHPunit v9.

In addition, expectException(Warning::class) is deprecated in PHPUnit v9,
which is modified as well, to make Core a small step towards PHPUnit v10 compat.

Resolves: #90787
Releases: master, 9.5
Change-Id: Ie8aedc3cf95b5fac84791cb2d7cedba642d481c7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63797
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/DateTimeTypesTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index aa26896..123c996 100644 (file)
@@ -105,7 +105,7 @@ class DateTimeTypesTest extends AbstractDataTypeBaseTestCase
     public function parseDateTimeTypeWithInvalidLowerBound()
     {
         $this->expectException(StatementException::class);
-        $this->expectExceptionMessageRegExp(
+        $this->expectDeprecationMessageMatches(
             '@Error: the fractional seconds part for TIME, DATETIME or TIMESTAMP columns must >= 0@'
         );
         $this->createSubject('TIME(-1)');
@@ -117,7 +117,7 @@ class DateTimeTypesTest extends AbstractDataTypeBaseTestCase
     public function parseDateTimeTypeWithInvalidUpperBound()
     {
         $this->expectException(StatementException::class);
-        $this->expectExceptionMessageRegExp(
+        $this->expectDeprecationMessageMatches(
             '@Error: the fractional seconds part for TIME, DATETIME or TIMESTAMP columns must <= 6@'
         );
         $this->createSubject('TIME(7)');
index d9fb3e1..ef6b0aa 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web\Routing;
  * The TYPO3 project - inspiring people to share!
  */
 
-use PHPUnit\Framework\Error\Warning;
 use TYPO3\CMS\Backend\Routing\Route;
 use TYPO3\CMS\Backend\Routing\Router;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -416,7 +415,7 @@ class UriBuilderTest extends UnitTestCase
     public function buildBackendUriHandlesRemovedMethods(string $method, string $expectedMessage, string $expectedResult): void
     {
         $_GET = ['common' => 'GET', 'get' => 'GET', 'route' => '/test/Path'];
-        $this->expectException(Warning::class);
+        $this->expectWarning();
         $this->expectExceptionMessage($expectedMessage);
         $this->uriBuilder->setAddQueryStringMethod($method);
         self::assertSame($expectedResult, $this->uriBuilder->buildFrontendUri());
index b96a726..bf9c361 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
-use PHPUnit\Framework\Error\Warning;
 use PHPUnit\Framework\Exception;
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -37,7 +36,6 @@ use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Site\Entity\Site;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\DebugUtility;
@@ -583,7 +581,7 @@ class ContentObjectRendererTest extends UnitTestCase
     {
         $_GET = ['common' => 'GET', 'get' => 'GET'];
         $configuration = ['method' => $method];
-        $this->expectException(Warning::class);
+        $this->expectWarning();
         $this->expectExceptionMessage($expectedMessage);
         self::assertSame($expectedResult, $this->subject->getQueryArguments($configuration));
     }