[TASK] Make RedirectServiceTest notice free 22/56222/5
authorSascha Löffler <lsascha@gmail.com>
Fri, 16 Mar 2018 13:06:57 +0000 (14:06 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Wed, 4 Apr 2018 15:51:27 +0000 (17:51 +0200)
Resolves: #84339
Releases: master
Change-Id: I6457c95e033a19e0e2bfa103070e75e3d42026de
Reviewed-on: https://review.typo3.org/56222
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/redirects/Classes/Service/RedirectService.php
typo3/sysext/redirects/Tests/Unit/Service/RedirectServiceTest.php

index dbcaaf8..5f0f8b3 100644 (file)
@@ -154,7 +154,7 @@ class RedirectService implements LoggerAwareInterface
         $linkDetails = $this->resolveLinkDetailsFromLinkTarget((string)$matchedRedirect['target']);
         $this->logger->debug('Resolved link details for redirect', $linkDetails);
         // Do this for files, folders, external URLs
-        if ($linkDetails['url']) {
+        if (!empty($linkDetails['url'])) {
             $url = new Uri($linkDetails['url']);
             if ($matchedRedirect['force_https']) {
                 $url = $url->withScheme('https');
index 7d26210..5143c25 100644 (file)
@@ -31,11 +31,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class RedirectServiceTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var RedirectCacheService|ObjectProphecy
      */
     protected $redirectCacheServiceProphecy;
@@ -55,6 +50,8 @@ class RedirectServiceTest extends UnitTestCase
         $this->redirectCacheServiceProphecy = $this->prophesize(RedirectCacheService::class);
         $this->redirectService = new RedirectService();
         $this->redirectService->setLogger($loggerProphecy->reveal());
+
+        $GLOBALS['SIM_ACCESS_TIME'] = 42;
     }
 
     /**
@@ -79,7 +76,10 @@ class RedirectServiceTest extends UnitTestCase
             'target' => 'https://example.com',
             'force_https' => '0',
             'keep_query_parameters' => '0',
-            'target_statuscode' => '307'
+            'target_statuscode' => '307',
+            'disabled' => '0',
+            'starttime' => '0',
+            'endtime' => '0'
         ];
         $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
             [
@@ -108,13 +108,19 @@ class RedirectServiceTest extends UnitTestCase
             'target' => 'https://example.com',
             'force_https' => '0',
             'keep_query_parameters' => '0',
-            'target_statuscode' => '307'
+            'target_statuscode' => '307',
+            'disabled' => '0',
+            'starttime' => '0',
+            'endtime' => '0'
         ];
         $row2 = [
             'target' => 'https://example.net',
             'force_https' => '0',
             'keep_query_parameters' => '0',
-            'target_statuscode' => '307'
+            'target_statuscode' => '307',
+            'disabled' => '0',
+            'starttime' => '0',
+            'endtime' => '0'
         ];
         $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
             [
@@ -150,7 +156,10 @@ class RedirectServiceTest extends UnitTestCase
             'target' => 'https://example.com',
             'force_https' => '0',
             'keep_query_parameters' => '0',
-            'target_statuscode' => '307'
+            'target_statuscode' => '307',
+            'disabled' => '0',
+            'starttime' => '0',
+            'endtime' => '0'
         ];
         $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
             [
@@ -180,6 +189,8 @@ class RedirectServiceTest extends UnitTestCase
             'force_https' => '0',
             'keep_query_parameters' => '0',
             'target_statuscode' => '307',
+            'starttime' => '0',
+            'endtime' => '0',
             'disabled' => '1'
         ];
         $row2 = [
@@ -187,6 +198,8 @@ class RedirectServiceTest extends UnitTestCase
             'force_https' => '0',
             'keep_query_parameters' => '0',
             'target_statuscode' => '307',
+            'starttime' => '0',
+            'endtime' => '0',
             'disabled' => '0'
         ];
         $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
@@ -230,6 +243,8 @@ class RedirectServiceTest extends UnitTestCase
         $linkServiceProphecy = $this->prophesize(LinkService::class);
         $redirectTargetMatch = [
             'target' => 'https://example.com',
+            'force_https' => '0',
+            'keep_query_parameters' => '0'
         ];
         $linkDetails = [
             'type' => LinkService::TYPE_URL,
@@ -254,6 +269,8 @@ class RedirectServiceTest extends UnitTestCase
         $fileProphecy->getPublicUrl()->willReturn('https://example.com/file.txt');
         $redirectTargetMatch = [
             'target' => 'https://example.com',
+            'force_https' => '0',
+            'keep_query_parameters' => '0',
         ];
         $linkDetails = [
             'type' => LinkService::TYPE_FILE,
@@ -278,6 +295,8 @@ class RedirectServiceTest extends UnitTestCase
         $folderProphecy->getPublicUrl()->willReturn('https://example.com/folder/');
         $redirectTargetMatch = [
             'target' => 'https://example.com',
+            'force_https' => '0',
+            'keep_query_parameters' => '0',
         ];
         $folder = $folderProphecy->reveal();
         $linkDetails = [
@@ -301,7 +320,8 @@ class RedirectServiceTest extends UnitTestCase
         $linkServiceProphecy = $this->prophesize(LinkService::class);
         $redirectTargetMatch = [
             'target' => 'https://example.com',
-            'force_https' => '1'
+            'keep_query_parameters' => '0',
+            'force_https' => '1',
         ];
         $linkDetails = [
             'type' => LinkService::TYPE_URL,
@@ -324,6 +344,7 @@ class RedirectServiceTest extends UnitTestCase
         $linkServiceProphecy = $this->prophesize(LinkService::class);
         $redirectTargetMatch = [
             'target' => 'https://example.com',
+            'force_https' => '0',
             'keep_query_parameters' => '1'
         ];
         $linkDetails = [