[TASK] Move arguments to initializeArguments() in TextfieldVH in ext:fluid 05/48905/6
authorRoberto Torresani <erreti@gmail.com>
Mon, 11 Jul 2016 14:57:37 +0000 (16:57 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 12 Jul 2016 09:57:10 +0000 (11:57 +0200)
Move the argument registrations away from the render() method
to initializeArguments(), to prevent any errors with PHP7 and
subclassed ViewHelpers if/when render() method signatures change
Change the UnitTest form TextfieldViewHelperTest with setArguments()
Introduce the function setArgumentsUnderTest()

Resolves: #77032
Releases: master
Change-Id: I21365e13d136ad10469c70b6cabec96d07c631f1
Reviewed-on: https://review.typo3.org/48905
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/UploadViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/PageViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ViewHelperBaseTestcase.php

index c7c86fe..95b8e23 100644 (file)
@@ -28,7 +28,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
  *
  * @api
  */
-class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
+class TextfieldViewHelper extends AbstractFormFieldViewHelper
 {
     /**
      * @var string
@@ -39,6 +39,7 @@ class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractForm
      * Initialize the arguments.
      *
      * @return void
+     * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
      * @api
      */
     public function initializeArguments()
@@ -53,18 +54,21 @@ class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractForm
         $this->registerTagAttribute('pattern', 'string', 'HTML5 validation pattern');
         $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', false, 'f3-form-error');
         $this->registerUniversalTagAttributes();
+        $this->registerArgument('required', 'bool', 'If the field is required or not', false, false);
+        $this->registerArgument('type', 'string', 'The field type, e.g. "text", "email", "url" etc.', false, 'text');
     }
 
     /**
      * Renders the textfield.
      *
-     * @param bool $required If the field is required or not
-     * @param string $type The field type, e.g. "text", "email", "url" etc.
      * @return string
      * @api
      */
-    public function render($required = false, $type = 'text')
+    public function render()
     {
+        $required = $this->arguments['required'];
+        $type = $this->arguments['type'];
+
         $name = $this->getName();
         $this->registerFieldNameForFormTokenGeneration($name);
         $this->setRespectSubmittedDataValue(true);
index d1d0623..6d4186e 100644 (file)
@@ -18,7 +18,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
 /**
  * Test for the "Select" Form view helper
  */
-class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
+class SelectViewHelperTest extends FormFieldViewHelperBaseTestcase
 {
     /**
      * @var \TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelper
@@ -43,6 +43,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['name'] = '';
         $this->arguments['sortByOptionLabel'] = false;
         $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelper::class, array('setErrorClassAttribute', 'registerFieldNameForFormTokenGeneration'));
+        $this->viewHelper->_set('tag', $this->tagBuilder);
     }
 
     protected function tearDown()
@@ -62,7 +63,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
 
         $this->arguments['options'] = array();
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -85,6 +86,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['name'] = 'myName';
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -122,6 +124,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         );
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -158,6 +161,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['options'] = array($obj1, $obj2, $obj3, $obj4);
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -195,6 +199,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         ));
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -213,7 +218,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['value'] = 'value2';
         $this->arguments['name'] = 'myName';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -238,7 +243,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['name'] = 'myName';
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -264,6 +269,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['sortByOptionLabel'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -299,6 +305,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['name'] = 'myName';
         $this->arguments['sortByOptionLabel'] = true;
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -321,7 +328,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['multiple'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initializeArguments();
         $this->viewHelper->initialize();
         $result = $this->viewHelper->render();
@@ -358,7 +365,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['optionLabelField'] = 'firstName';
         $this->arguments['name'] = 'myName';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -386,7 +393,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['multiple'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initializeArguments();
         $this->viewHelper->initialize();
         $actual = $this->viewHelper->render();
@@ -426,7 +433,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['multiple'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initializeArguments();
         $this->viewHelper->initialize();
         $actual = $this->viewHelper->render();
@@ -460,7 +467,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         );
         $this->arguments['name'] = 'myName';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -490,7 +497,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         );
         $this->arguments['name'] = 'myName';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -514,7 +521,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         );
         $this->arguments['name'] = 'myName';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -527,7 +534,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['options'] = array();
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
         $this->viewHelper->render();
     }
@@ -549,7 +556,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['selectAllByDefault'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -572,7 +579,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['selectAllByDefault'] = true;
 
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -594,6 +601,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['name'] = 'myName';
         $this->arguments['prependOptionLabel'] = 'please choose';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
@@ -616,6 +624,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         $this->arguments['prependOptionLabel'] = 'please choose';
         $this->arguments['prependOptionValue'] = '-1';
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
+
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
index d31e667..8e329fb 100644 (file)
@@ -14,25 +14,26 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
+use TYPO3\CMS\Extbase\Reflection\ReflectionService;
+use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode;
+use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
+use TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper;
 
 /**
  * Test for the "Textfield" Form view helper
  */
-class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
+class TextfieldViewHelperTest extends ViewHelperBaseTestcase
 {
     /**
-     * @var \TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper
+     * @var TextfieldViewHelper
      */
     protected $viewHelper;
 
     protected function setUp()
     {
         parent::setUp();
-        $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper::class, array('setErrorClassAttribute', 'registerFieldNameForFormTokenGeneration'));
-        $this->arguments['name'] = '';
+        $this->viewHelper = new TextfieldViewHelper();
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-        $this->viewHelper->initializeArguments();
     }
 
     /**
@@ -40,15 +41,13 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
      */
     public function renderCorrectlySetsTagName()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName'))
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
-        $this->viewHelper->_set('tag', $mockTagBuilder);
+        $this->setArgumentsUnderTest(
+            $this->viewHelper
+        );
 
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $expectedResult = '<input type="text" name="" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 
     /**
@@ -56,26 +55,19 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
      */
     public function renderCorrectlySetsTypeNameAndValueAttributes()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('addAttribute', 'setContent', 'render'))
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('type', 'text');
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'NameOfTextfield');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('NameOfTextfield');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('value', 'Current value');
-        $mockTagBuilder->expects($this->once())->method('render');
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $arguments = array(
-            'name' => 'NameOfTextfield',
-            'value' => 'Current value'
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'name' => 'NameOfTextfield',
+                'value' => 'Current value',
+                'type' => 'text'
+            ]
         );
-        $this->viewHelper->setArguments($arguments);
 
-        $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->viewHelper->setViewHelperNode(new EmptySyntaxTreeNode());
+        $expectedResult = '<input type="text" name="NameOfTextfield" value="Current value" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 
     /**
@@ -83,6 +75,17 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
      */
     public function renderCallsSetErrorClassAttribute()
     {
+        $this->viewHelper = $this->getAccessibleMock(
+            TextfieldViewHelper::class,
+            [
+                'setErrorClassAttribute',
+                'registerFieldNameForFormTokenGeneration'
+            ]
+        );
+        $this->injectDependenciesIntoViewHelper($this->viewHelper);
+        $reflectionServiceProphecy = $this->prophesize(ReflectionService::class);
+        $this->viewHelper->injectReflectionService($reflectionServiceProphecy->reveal());
+
         $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
         $this->viewHelper->render();
     }
@@ -92,25 +95,19 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
      */
     public function renderAddsPlaceholder()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('addAttribute', 'setContent', 'render'))
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('placeholder', 'SomePlaceholder');
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'text');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'NameOfTextfield');
-        $mockTagBuilder->expects($this->once())->method('render');
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $arguments = array(
-            'name' => 'NameOfTextfield',
-            'placeholder' => 'SomePlaceholder'
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'name' => 'NameOfTextfield',
+                'placeholder' => 'SomePlaceholder',
+                'type' => 'text'
+            ]
         );
-        $this->viewHelper->setArguments($arguments);
 
-        $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->viewHelper->setViewHelperNode(new EmptySyntaxTreeNode());
+        $expectedResult = '<input placeholder="SomePlaceholder" type="text" name="NameOfTextfield" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 
     /**
@@ -118,26 +115,19 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
      */
     public function renderCorrectlySetsRequiredAttribute()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('addAttribute', 'setContent', 'render'))
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('type', 'text');
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'NameOfTextfield');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('NameOfTextfield');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('value', 'Current value');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('required', 'required');
-        $mockTagBuilder->expects($this->once())->method('render');
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $arguments = array(
-            'name' => 'NameOfTextfield',
-            'value' => 'Current value'
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'name' => 'NameOfTextfield',
+                'value' => 'Current value',
+                'type' => 'text',
+                'required' => 'required'
+            ]
         );
-        $this->viewHelper->setArguments($arguments);
 
-        $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
-        $this->viewHelper->initialize();
-        $this->viewHelper->render(true);
+        $this->viewHelper->setViewHelperNode(new EmptySyntaxTreeNode());
+        $expectedResult = '<input type="text" name="NameOfTextfield" value="Current value" required="required" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 }
index bc6f9ee..1f61458 100644 (file)
@@ -40,7 +40,7 @@ class UploadViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
     public function renderCorrectlySetsTagName()
     {
         $this->tagBuilder->expects($this->once())->method('setTagName')->with('input');
-
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->initialize();
         $this->viewHelper->render();
     }
index e2e6703..8e7dd48 100644 (file)
@@ -101,6 +101,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $this->viewHelperVariableContainer->expects($this->at(1))->method('add')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties', array());
         $this->viewHelperVariableContainer->expects($this->at(2))->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject');
         $this->viewHelperVariableContainer->expects($this->at(3))->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -115,6 +116,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(array('name' => $objectName));
         $this->viewHelperVariableContainer->expects($this->once())->method('add')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName', $objectName);
         $this->viewHelperVariableContainer->expects($this->once())->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -129,6 +131,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(array('name' => 'formName', 'objectName' => $objectName));
         $this->viewHelperVariableContainer->expects($this->once())->method('add')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName', $objectName);
         $this->viewHelperVariableContainer->expects($this->once())->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -140,6 +143,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, array('renderChildren', 'renderRequestHashField', 'renderHiddenReferrerFields', 'renderTrustedPropertiesField'), array(), '', false);
         $viewHelper->expects($this->once())->method('renderHiddenReferrerFields');
         $this->injectDependenciesIntoViewHelper($viewHelper);
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -154,6 +158,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(array('object' => $object));
         $viewHelper->expects($this->atLeastOnce())->method('getFormObjectName')->will($this->returnValue('MyName'));
         $viewHelper->expects($this->once())->method('renderHiddenIdentityField')->with($object, 'MyName');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -165,6 +170,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, array('renderChildren', 'renderRequestHashField', 'renderHiddenReferrerFields', 'renderAdditionalIdentityFields', 'renderTrustedPropertiesField'), array(), '', false);
         $viewHelper->expects($this->once())->method('renderAdditionalIdentityFields');
         $this->injectDependenciesIntoViewHelper($viewHelper);
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -183,6 +189,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('formContent'));
         $expectedResult = chr(10) . '<div>' . 'hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . chr(10) . '</div>' . chr(10) . 'formContent';
         $this->tagBuilder->expects($this->once())->method('setContent')->with($expectedResult);
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -205,6 +212,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $expectedResult = chr(10) . '<div class="hidden">' . 'hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . chr(10) . '</div>' . chr(10) . 'formContent';
         $this->tagBuilder->expects($this->once())->method('setContent')->with($expectedResult);
         $viewHelper->setArguments(array('hiddenFieldClassName' => 'hidden'));
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -223,6 +231,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $this->injectDependenciesIntoViewHelper($viewHelper);
         $expected = chr(10) . '<input type="hidden" name="object1[object2][__identity]" value="42" />' . chr(10) . '<input type="hidden" name="object1[object2][subobject][__identity]" value="21" />';
         $actual = $viewHelper->_call('renderAdditionalIdentityFields');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $this->assertEquals($expected, $actual);
     }
 
@@ -242,6 +251,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
             . chr(10) . '<input type="hidden" name="__referrer[@action]" value="controllerActionName" />'
             . chr(10) . '<input type="hidden" name="__referrer[arguments]" value="" />'
             . chr(10) . '<input type="hidden" name="__referrer[@request]" value="" />' . chr(10);
+        $viewHelper->_set('tag', $this->tagBuilder);
         $this->assertEquals($expectedResult, $hiddenFields);
     }
 
@@ -256,6 +266,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(array('fieldNamePrefix' => $prefix));
         $this->viewHelperVariableContainer->expects($this->once())->method('add')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix', $prefix);
         $this->viewHelperVariableContainer->expects($this->once())->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -272,6 +283,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(array('extensionName' => 'SomeExtension', 'pluginName' => 'SomePlugin'));
         $this->viewHelperVariableContainer->expects($this->once())->method('add')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix', $expectedPrefix);
         $this->viewHelperVariableContainer->expects($this->once())->method('remove')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix');
+        $viewHelper->_set('tag', $this->tagBuilder);
         $viewHelper->render();
     }
 
index a48f198..56dd5b1 100644 (file)
@@ -43,6 +43,7 @@ class PageViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHel
     {
         $this->uriBuilder->expects($this->once())->method('build')->will($this->returnValue('index.php'));
         $this->tagBuilder->expects($this->once())->method('render');
+        $this->viewHelper->_set('tag', $this->tagBuilder);
         $this->viewHelper->render();
     }
 
index f20f244..16a5c87 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
 use TYPO3\CMS\Extbase\Reflection\ReflectionService;
 use TYPO3\CMS\Fluid\Core\Variables\CmsVariableProvider;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface;
 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
@@ -114,9 +113,6 @@ abstract class ViewHelperBaseTestcase extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $viewHelper->setRenderingContext($this->renderingContext);
         $viewHelper->setArguments($this->arguments);
-        if ($viewHelper instanceof \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper || $viewHelper instanceof AbstractTagBasedViewHelper) {
-            $viewHelper->_set('tag', $this->tagBuilder);
-        }
         if ($viewHelper instanceof AbstractViewHelper) {
             $reflectionServiceProphecy = $this->prophesize(ReflectionService::class);
             $viewHelper->injectReflectionService($reflectionServiceProphecy->reveal());