[BUGFIX] ViewHelper variable container must deal with NULL 33/42133/5
authorAndreas Treichel <a.treichel+typo3@eraffe-media.de>
Thu, 30 Jul 2015 10:23:36 +0000 (12:23 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 5 Aug 2015 16:27:38 +0000 (18:27 +0200)
The internal variable storage container for viewhelpers must
be capable of handling variables with NULL values.

Resolves: #59255
Releases: master, 6.2
Change-Id: I0a9adea3e123a56c2425ff855cc95144732cb900
Reviewed-on: http://review.typo3.org/42133
Reviewed-by: Björn Fromme <mail@bjo3rn.com>
Tested-by: Björn Fromme <mail@bjo3rn.com>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperVariableContainer.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperVariableContainerTest.php

index 7efe8d9..f1fca90 100644 (file)
@@ -91,7 +91,7 @@ class ViewHelperVariableContainer {
         * @api
         */
        public function exists($viewHelperName, $key) {
-               return isset($this->objects[$viewHelperName][$key]);
+               return isset($this->objects[$viewHelperName]) && array_key_exists($key, $this->objects[$viewHelperName]);
        }
 
        /**
index 148a5a3..c6c8165 100644 (file)
@@ -89,4 +89,28 @@ class ViewHelperVariableContainerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $this->assertSame($view, $this->viewHelperVariableContainer->getView());
        }
 
+
+       /**
+        * @test
+        */
+       public function existsReturnsFalseIfTheSpecifiedKeyDoesNotExist() {
+               $this->assertFalse($this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelper\NonExistent', 'nonExistentKey'));
+       }
+
+       /**
+        * @test
+        */
+       public function existsReturnsTrueIfTheSpecifiedKeyExists() {
+               $this->viewHelperVariableContainer->add('TYPO3\Fluid\ViewHelper\NonExistent', 'someKey', 'someValue');
+               $this->assertTrue($this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelper\NonExistent', 'someKey'));
+       }
+
+       /**
+        * @test
+        */
+       public function existsReturnsTrueIfTheSpecifiedKeyExistsAndIsNull() {
+               $this->viewHelperVariableContainer->add('TYPO3\Fluid\ViewHelper\NonExistent', 'someKey', NULL);
+               $this->assertTrue($this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelper\NonExistent', 'someKey'));
+       }
+
 }