Revert "[FEATURE] Fallback/default case for SwitchViewhelper" 55/26055/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 8 Dec 2013 15:29:31 +0000 (16:29 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 8 Dec 2013 15:29:53 +0000 (16:29 +0100)
This reverts commit 8e022bcbea4f7775ce10fee30b4682a6047c461c

Merged a Feature after Feature Freeze is not acceptable. Sorry. Patch is pushed new but will not be available in 6.2.

Change-Id: I39baa58c70b0e942d01c1c37bbf793b873db385d
Reviewed-on: https://review.typo3.org/26055
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/fluid/Classes/ViewHelpers/CaseViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/SwitchViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/CaseViewHelperTest.php

index 28bc487..21a834f 100644 (file)
@@ -20,26 +20,20 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
 class CaseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
 
        /**
-        * @param mixed $value The switch value. If it matches, the child will be rendered
-        * @param boolean $default If this is set, this child will be rendered, if none else matches
-        *
-        * @return string the contents of this view helper if $value equals the expression of the surrounding switch view helper, or $default is TRUE. otherwise an empty string
+        * @param mixed $value
+        * @return string the contents of this view helper if $value equals the expression of the surrounding switch view helper, otherwise an empty string
         * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
-        *
         * @api
         */
-       public function render($value = NULL, $default = FALSE) {
+       public function render($value) {
                $viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
                if (!$viewHelperVariableContainer->exists('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')) {
                        throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('The case View helper can only be used within a switch View helper', 1368112037);
                }
-               if (is_null($value) && $default === FALSE) {
-                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('The case View helper must have either value or default argument', 1382867521);
-               }
                $switchExpression = $viewHelperVariableContainer->get('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression');
 
                // non-type-safe comparison by intention
-               if ($default === TRUE || $switchExpression == $value) {
+               if ($switchExpression == $value) {
                        $viewHelperVariableContainer->addOrUpdate('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'break', TRUE);
                        return $this->renderChildren();
                }
index 36b146f..5845355 100644 (file)
@@ -21,11 +21,10 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  * <f:switch expression="{person.gender}">
  *   <f:case value="male">Mr.</f:case>
  *   <f:case value="female">Mrs.</f:case>
- *   <f:case default="TRUE">Mrs. or Mr.</f:case>
  * </f:switch>
  * </code>
  * <output>
- * Mr. / Mrs. (depending on the value of {person.gender}) or if no value evaluates to TRUE, default case
+ * Mr. / Mrs. (depending on the value of {person.gender})
  * </output>
  *
  * Note: Using this view helper can be a sign of weak architecture. If you end up using it extensively
index 4c2276e..18427e6 100644 (file)
@@ -87,64 +87,4 @@ class CaseViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHel
                $this->assertSame('', $this->viewHelper->render('someOtherValue'));
        }
 
-       /**
-        * @test
-        */
-       public function renderReturnsChildNodesIfDefaultIsTrue() {
-               $this->viewHelperVariableContainer->expects(
-                       $this->atLeastOnce())
-                       ->method('exists')
-                       ->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')
-                       ->will($this->returnValue(TRUE)
-                       );
-               $this->viewHelperVariableContainer->expects(
-                       $this->atLeastOnce())->method('get')
-                       ->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')
-                       ->will($this->returnValue(NULL)
-                       );
-
-               $renderedChildNodes = 'ChildNodes';
-               $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue($renderedChildNodes));
-
-               $this->assertSame($renderedChildNodes, $this->viewHelper->render(NULL, TRUE));
-       }
-
-       /**
-        * @test
-        * @expectedException \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
-        */
-       public function renderThrowsExceptionIfNeighterValueNorDefaultAreGiven() {
-               $this->viewHelperVariableContainer->expects(
-                       $this->atLeastOnce())
-                       ->method('exists')
-                       ->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')
-                       ->will($this->returnValue(TRUE)
-                       );
-               $this->viewHelperVariableContainer->expects($this->never())->method('get');
-
-               $this->viewHelper->render(NULL, FALSE);
-       }
-
-       /**
-        * @test
-        */
-       public function renderReturnsChildNodesEvenIfValueIsFalseButDefaultIsTrue() {
-               $this->viewHelperVariableContainer->expects(
-                       $this->atLeastOnce())
-                       ->method('exists')
-                       ->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')
-                       ->will($this->returnValue(TRUE)
-                       );
-               $this->viewHelperVariableContainer->expects(
-                       $this->atLeastOnce())->method('get')
-                       ->with('TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper', 'switchExpression')
-                       ->will($this->returnValue('someValue')
-                       );
-
-               $renderedChildNodes = 'ChildNodes';
-               $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue($renderedChildNodes));
-
-               $this->assertSame($renderedChildNodes, $this->viewHelper->render('someOtherValue', TRUE));
-       }
-
 }