[TASK] Make form/Tests/Unit/Domain/FormElements/ notice free 73/56273/2
authorJan Helke <typo3@helke.de>
Sat, 17 Mar 2018 08:52:17 +0000 (09:52 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 10:10:19 +0000 (11:10 +0100)
Releases: master
Resolves: #84397
Change-Id: I0882fa642505bd2122885b83538d6f32ddbee293
Reviewed-on: https://review.typo3.org/56273
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/form/Classes/Domain/Model/FormElements/AbstractFormElement.php
typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/SectionTest.php

index 7820f83..c68db7d 100644 (file)
@@ -147,7 +147,7 @@ abstract class AbstractFormElement extends AbstractRenderable implements FormEle
      */
     public function setProperty(string $key, $value)
     {
-        if (is_array($value) && is_array($this->properties[$key])) {
+        if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) {
             ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value);
         } else {
             $this->properties[$key] = $value;
index 5c237b9..cb2484d 100644 (file)
@@ -117,7 +117,7 @@ class Section extends AbstractSection implements FormElementInterface
      */
     public function setProperty(string $key, $value)
     {
-        if (is_array($value) && is_array($this->properties[$key])) {
+        if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) {
             ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value);
         } else {
             $this->properties[$key] = $value;
index 29711ea..9170bdd 100644 (file)
@@ -14,14 +14,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class AbstractFormElementTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @test
      */
-    public function newInstanceHasNoProperties()
+    public function newInstanceHasNoProperties(): void
     {
         /** @var AbstractFormElement $subject */
         $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
@@ -32,7 +27,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function setSimpleProperties()
+    public function setSimpleProperties(): void
     {
         /** @var AbstractFormElement $subject */
         $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
@@ -51,7 +46,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function overrideProperties()
+    public function overrideProperties(): void
     {
         /** @var AbstractFormElement $subject */
         $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
@@ -60,7 +55,7 @@ class AbstractFormElementTest extends UnitTestCase
         $subject->setProperty('foo', 'buz');
 
         $properties = $subject->getProperties();
-        $this->assertEquals(1, count($properties));
+        $this->assertEquals(1, \count($properties));
         $this->assertTrue(array_key_exists('foo', $properties));
         $this->assertEquals('buz', $properties['foo']);
     }
@@ -68,7 +63,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArrayProperties()
+    public function setArrayProperties(): void
     {
         /** @var AbstractFormElement $subject */
         $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
@@ -80,7 +75,7 @@ class AbstractFormElementTest extends UnitTestCase
         $this->assertTrue(array_key_exists('foo', $properties));
 
         //check arrays details
-        $this->assertTrue(is_array($properties['foo']));
+        $this->assertTrue(\is_array($properties['foo']));
         $this->assertCount(2, $properties['foo']);
         $this->assertTrue(array_key_exists('bar', $properties['foo']));
         $this->assertEquals('baz', $properties['foo']['bar']);
@@ -89,7 +84,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructThrowsExceptionWhenIdentifierIsEmpty()
+    public function constructThrowsExceptionWhenIdentifierIsEmpty(): void
     {
         $this->expectException(IdentifierNotValidException::class);
         $this->expectExceptionCode(1477082502);
@@ -108,7 +103,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString()
+    public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString(): void
     {
         $mock = $this->getAccessibleMockForAbstractClass(
             AbstractFormElement::class,
@@ -125,7 +120,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function initializeFormElementExpectedCallInitializeFormObjectHooks()
+    public function initializeFormElementExpectedCallInitializeFormObjectHooks(): void
     {
         /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock */
         $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
@@ -155,10 +150,10 @@ class AbstractFormElementTest extends UnitTestCase
             ->method('initializeFormElement')
             ->with($abstractFormElementMock);
 
-        GeneralUtility::addInstance(get_class($secondMock), $secondMock);
+        GeneralUtility::addInstance(\get_class($secondMock), $secondMock);
 
         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] = [
-            get_class($secondMock)
+            \get_class($secondMock)
         ];
 
         $abstractFormElementMock->initializeFormElement();
@@ -167,7 +162,7 @@ class AbstractFormElementTest extends UnitTestCase
     /**
      * @test
      */
-    public function getUniqueIdentifierExpectedUnique()
+    public function getUniqueIdentifierExpectedUnique(): void
     {
         /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock1 */
         $abstractFormElementMock1 = $this->getAccessibleMockForAbstractClass(
index 629676f..fd48763 100644 (file)
@@ -1,20 +1,17 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Form\Tests\Unit\Domain\FormElements;
 
 use TYPO3\CMS\Form\Domain\Model\FormElements\Section;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test TYPO3\CMS\Form\Domain\Model\FormElements\Section class
  *
  * Class AbstractFormElementTest
  */
-class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class SectionTest extends UnitTestCase
 {
-    /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
     protected static $IDENTIFIER = 'an_id';
     protected static $TYPE = 'a_type';
 
@@ -22,7 +19,7 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * An instance of section
      * @var Section
      */
-    protected $sectionInstance = null;
+    protected $sectionInstance;
 
     /**
      * @before
@@ -36,7 +33,7 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function newInstanceHasNoProperties()
+    public function newInstanceHasNoProperties(): void
     {
         $this->assertNotNull($this->sectionInstance);
         $this->assertCount(0, $this->sectionInstance->getProperties());
@@ -45,7 +42,7 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function setSimpleProperties()
+    public function setSimpleProperties(): void
     {
         $this->sectionInstance->setProperty('foo', 'bar');
         $this->sectionInstance->setProperty('buz', 'qax');
@@ -61,13 +58,13 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function overrideProperties()
+    public function overrideProperties(): void
     {
         $this->sectionInstance->setProperty('foo', 'bar');
         $this->sectionInstance->setProperty('foo', 'buz');
 
         $properties = $this->sectionInstance->getProperties();
-        $this->assertEquals(1, count($properties));
+        $this->assertEquals(1, \count($properties));
         $this->assertTrue(array_key_exists('foo', $properties));
         $this->assertEquals('buz', $properties['foo']);
     }
@@ -75,7 +72,7 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function setArrayProperties()
+    public function setArrayProperties(): void
     {
         $this->sectionInstance->setProperty('foo', ['bar' => 'baz', 'bla' => 'blubb']);
         $properties = $this->sectionInstance->getProperties();
@@ -84,7 +81,7 @@ class SectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->assertTrue(array_key_exists('foo', $properties));
 
         //check arrays details
-        $this->assertTrue(is_array($properties['foo']));
+        $this->assertTrue(\is_array($properties['foo']));
         $this->assertCount(2, $properties['foo']);
         $this->assertTrue(array_key_exists('bar', $properties['foo']));
         $this->assertEquals('baz', $properties['foo']['bar']);