[TASK] Make typo3/sysext/frontend/Tests/Unit/ContentObject notice free 20/57220/5
authorJan Helke <typo3@helke.de>
Fri, 15 Jun 2018 09:50:40 +0000 (11:50 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 15 Jun 2018 13:12:05 +0000 (15:12 +0200)
Releases: master
Resolves: #85263
Change-Id: I19e7a26ddf41d7b55dfd1890163364ffd2479e13
Reviewed-on: https://review.typo3.org/57220
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/frontend/Classes/ContentObject/CaseContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/CaseContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php

index 4d6a86c..8023bb3 100644 (file)
@@ -31,17 +31,19 @@ class CaseContentObject extends AbstractContentObject
             return '';
         }
 
-        $setCurrent = isset($conf['setCurrent.']) ? $this->cObj->stdWrap($conf['setCurrent'], $conf['setCurrent.']) : $conf['setCurrent'];
+        $setCurrent = isset($conf['setCurrent.'])
+            ? $this->cObj->stdWrap($conf['setCurrent'] ?? '', $conf['setCurrent.'])
+            : ($conf['setCurrent'] ?? null);
         if ($setCurrent) {
             $this->cObj->data[$this->cObj->currentValKey] = $setCurrent;
         }
         $key = isset($conf['key.']) ? $this->cObj->stdWrap($conf['key'], $conf['key.']) : $conf['key'];
-        $key = (string)$conf[$key] !== '' ? $key : 'default';
+        $key = isset($conf[$key]) && (string)$conf[$key] !== '' ? $key : 'default';
         // If no "default" property is available, then an empty string is returned
-        if ($key === 'default' && $conf['default'] === null) {
+        if ($key === 'default' && !isset($conf['default'])) {
             $theValue = '';
         } else {
-            $theValue = $this->cObj->cObjGetSingle($conf[$key], $conf[$key . '.'], $key);
+            $theValue = $this->cObj->cObjGetSingle($conf[$key], $conf[$key . '.'] ?? [], $key);
         }
         if (isset($conf['stdWrap.'])) {
             $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
index 3e53e88..a9742e7 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
 
 /*
@@ -33,19 +35,14 @@ class CaseContentObjectTest extends UnitTestCase
     protected $resetSingletonInstances = true;
 
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var CaseContentObject|\PHPUnit_Framework_MockObject_MockObject
      */
-    protected $subject = null;
+    protected $subject;
 
     /**
      * Set up
      */
-    protected function setUp()
+    protected function setUp(): void
     {
         /** @var TypoScriptFrontendController $tsfe */
         $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
@@ -73,7 +70,7 @@ class CaseContentObjectTest extends UnitTestCase
     /**
      * @test
      */
-    public function renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet()
+    public function renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet(): void
     {
         $conf = [
             'key' => 'not existing'
@@ -84,7 +81,7 @@ class CaseContentObjectTest extends UnitTestCase
     /**
      * @test
      */
-    public function renderReturnsContentFromDefaultObjectIfKeyDoesNotExist()
+    public function renderReturnsContentFromDefaultObjectIfKeyDoesNotExist(): void
     {
         $conf = [
             'key' => 'not existing',
index 864b143..7db588b 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
 
 /*
@@ -16,21 +18,22 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
 use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures\DataProcessorFixture;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Testcase for TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor
  */
-class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ContentDataProcessorTest extends UnitTestCase
 {
     /**
      * @var ContentDataProcessor
      */
-    protected $contentDataProcessor = null;
+    protected $contentDataProcessor;
 
     /**
      * Set up
      */
-    protected function setUp()
+    protected function setUp(): void
     {
         $this->contentDataProcessor = new ContentDataProcessor();
     }
@@ -38,7 +41,7 @@ class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
     /**
      * @test
      */
-    public function throwsExceptionIfProcessorClassDoesNotExist()
+    public function throwsExceptionIfProcessorClassDoesNotExist(): void
     {
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1427455378);
@@ -55,7 +58,7 @@ class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
     /**
      * @test
      */
-    public function throwsExceptionIfProcessorClassDoesNotImplementInterface()
+    public function throwsExceptionIfProcessorClassDoesNotImplementInterface(): void
     {
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1427455377);
@@ -72,7 +75,7 @@ class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
     /**
      * @test
      */
-    public function processorIsCalled()
+    public function processorIsCalled(): void
     {
         $contentObjectRendererStub = new ContentObjectRenderer();
         $config = [
@@ -82,6 +85,9 @@ class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             ]
         ];
         $variables = [];
-        $this->assertSame(['foo' => 'bar'], $this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables));
+        $this->assertSame(
+            ['foo' => 'bar'],
+            $this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables)
+        );
     }
 }