[TASK] Make ImageScriptServiceTest notice free 06/56306/3
authorŁukasz Uznański <l.uznanski@macopedia.pl>
Sat, 17 Mar 2018 14:01:12 +0000 (15:01 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 16:05:03 +0000 (17:05 +0100)
Resolves: #84432
Releases: master
Change-Id: Ia5e0ee072bba182f1a842b2b1d470f4c8fc80798
Reviewed-on: https://review.typo3.org/56306
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extbase/Tests/Unit/Service/ImageScriptServiceTest.php

index 76289de..bf9f4c4 100644 (file)
@@ -2814,12 +2814,12 @@ class GeneralUtility
                 if ($proxySSL === '*') {
                     $proxySSL = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'];
                 }
-                if (self::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL)) {
+                if (self::cmpIP($_SERVER['REMOTE_ADDR'] ?? '', $proxySSL)) {
                     $retVal = true;
                 } else {
                     // https://secure.php.net/manual/en/reserved.variables.server.php
                     // "Set to a non-empty value if the script was queried through the HTTPS protocol."
-                    $retVal = $_SERVER['SSL_SESSION_ID']
+                    $retVal = !empty($_SERVER['SSL_SESSION_ID'])
                         || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
                 }
                 break;
index c7be01b..14eb1dc 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Extbase\Tests\Unit\Service;
 
 /*
@@ -20,18 +21,14 @@ use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
 use TYPO3\CMS\Extbase\Service\ImageService;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ImageScriptServiceTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var ImageService
      */
     protected $subject;
@@ -44,7 +41,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     /**
      * Initialize ImageService and environment service mock
      */
-    protected function setUp()
+    protected function setUp(): void
     {
         $this->environmentService = $this->createMock(EnvironmentService::class);
         $this->subject = new ImageService($this->environmentService);
@@ -55,7 +52,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     /**
      * @test
      */
-    public function fileIsUnwrappedFromReferenceForProcessing()
+    public function fileIsUnwrappedFromReferenceForProcessing(): void
     {
         $reference = $this->getAccessibleMock(FileReference::class, [], [], '', false);
         $file = $this->createMock(File::class);
@@ -69,7 +66,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     /**
      * @return array
      */
-    public function prefixIsCorrectlyAppliedToGetImageUriDataProvider()
+    public function prefixIsCorrectlyAppliedToGetImageUriDataProvider(): array
     {
         return [
             'with scheme' => ['http://foo.bar/img.jpg', 'http://foo.bar/img.jpg'],
@@ -82,7 +79,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      * @test
      * @dataProvider prefixIsCorrectlyAppliedToGetImageUriDataProvider
      */
-    public function prefixIsCorrectlyAppliedToGetImageUri($imageUri, $expected)
+    public function prefixIsCorrectlyAppliedToGetImageUri($imageUri, $expected): void
     {
         $this->environmentService->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(true);
         $GLOBALS['TSFE'] = new \stdClass();
@@ -97,7 +94,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     /**
      * @return array
      */
-    public function prefixIsCorrectlyAppliedToGetImageUriWithAbsolutePathDataProvider()
+    public function prefixIsCorrectlyAppliedToGetImageUriWithAbsolutePathDataProvider(): array
     {
         return [
             'with scheme' => ['http://foo.bar/img.jpg', 'http://foo.bar/img.jpg'],
@@ -110,7 +107,7 @@ class ImageScriptServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      * @test
      * @dataProvider prefixIsCorrectlyAppliedToGetImageUriWithAbsolutePathDataProvider
      */
-    public function prefixIsCorrectlyAppliedToGetImageUriWithForcedAbsoluteUrl($imageUri, $expected)
+    public function prefixIsCorrectlyAppliedToGetImageUriWithForcedAbsoluteUrl($imageUri, $expected): void
     {
         $this->environmentService->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(true);
         $GLOBALS['TSFE'] = new \stdClass();