[TASK] Move arguments to initializeArguments() in RadioVH in ext:fluid 85/48885/9
authorRoberto Torresani <erreti@gmail.com>
Mon, 11 Jul 2016 09:03:30 +0000 (11:03 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Thu, 21 Jul 2016 05:24:29 +0000 (07:24 +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 RadioViewHelperTest with setArguments().

Resolves: #77023
Releases: master
Change-Id: I211090b546f1faaef49b3c0b6713ee9f58836224
Reviewed-on: https://review.typo3.org/48885
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Roberto Torresani <erreti@gmail.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/CheckboxViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/RadioViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ViewHelperBaseTestcase.php

index 2e62d7a..9d73293 100644 (file)
@@ -62,25 +62,27 @@ class RadioViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFiel
     public function initializeArguments()
     {
         parent::initializeArguments();
-        $this->registerTagAttribute(
-            'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
-        );
         $this->registerArgument(
             'errorClass', 'string', 'CSS class to set if there are errors for this view helper', false, 'f3-form-error'
         );
+        $this->registerArgument('checked', 'bool', 'Specifies that the input element should be preselected');
         $this->overrideArgument('value', 'string', 'Value of input tag. Required for radio buttons', true);
         $this->registerUniversalTagAttributes();
+        $this->registerTagAttribute(
+            'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+        );
     }
 
     /**
      * Renders the checkbox.
      *
-     * @param bool $checked Specifies that the input element should be preselected
      * @return string
      * @api
      */
-    public function render($checked = null)
+    public function render()
     {
+        $checked = $this->arguments['checked'];
+
         $this->tag->addAttribute('type', 'radio');
 
         $nameAttribute = $this->getName();
@@ -96,7 +98,6 @@ class RadioViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFiel
         }
 
         if ($propertyValue !== null) {
-
             // no type-safe comparison by intention
             $checked = $propertyValue == $valueAttribute;
         }
index c9760ec..b970ad6 100644 (file)
@@ -2,7 +2,6 @@
 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
 
 use Prophecy\Argument;
-use TYPO3\CMS\Extbase\Error\Result;
 use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
 use TYPO3\CMS\Fluid\ViewHelpers\Form\CheckboxViewHelper;
@@ -371,48 +370,4 @@ class CheckboxViewHelperTest extends ViewHelperBaseTestcase
             $result
         );
     }
-
-    /**
-     * Helper function for a valid mapping result
-     */
-    protected function stubRequestWithoutMappingErrors()
-    {
-        $this->request->getOriginalRequest()->willReturn(null);
-        $this->request->getArguments()->willReturn([]);
-        $result = $this->prophesize(Result::class);
-        $result->forProperty('objectName')->willReturn($result->reveal());
-        $result->forProperty('someProperty')->willReturn($result->reveal());
-        $result->hasErrors()->willReturn(false);
-        $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
-    }
-
-    /**
-     * Helper function for a mapping result with errors
-     */
-    protected function stubRequestWithMappingErrors()
-    {
-        $this->request->getOriginalRequest()->willReturn(null);
-        $this->request->getArguments()->willReturn([]);
-        $result = $this->prophesize(Result::class);
-        $result->forProperty('objectName')->willReturn($result->reveal());
-        $result->forProperty('someProperty')->willReturn($result->reveal());
-        $result->hasErrors()->willReturn(true);
-        $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
-    }
-
-    /**
-     * Helper function for the bound property
-     *
-     * @param $formObject
-     */
-    protected function stubVariableContainer($formObject)
-    {
-        $this->viewHelperVariableContainer->exists(Argument::cetera())->willReturn(true);
-        $this->viewHelperVariableContainer->get(Argument::any(), 'formObjectName')->willReturn('objectName');
-        $this->viewHelperVariableContainer->get(Argument::any(), 'fieldNamePrefix')->willReturn('fieldPrefix');
-        $this->viewHelperVariableContainer->get(Argument::any(), 'formFieldNames')->willReturn([]);
-        $this->viewHelperVariableContainer->get(Argument::any(), 'formObject')->willReturn($formObject);
-        $this->viewHelperVariableContainer->get(Argument::any(), 'renderedHiddenFields')->willReturn([]);
-        $this->viewHelperVariableContainer->addOrUpdate(Argument::cetera())->willReturn(null);
-    }
 }
index b0e897b..a199cbe 100644 (file)
@@ -13,13 +13,15 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
+use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
 use TYPO3\CMS\Fluid\ViewHelpers\Form\RadioViewHelper;
-use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
 
 /**
  * Test for the "Radio" Form view helper
  */
-class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
+class RadioViewHelperTest extends ViewHelperBaseTestcase
 {
     /**
      * @var \TYPO3\CMS\Fluid\ViewHelpers\Form\RadioViewHelper
@@ -29,31 +31,24 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
     protected function setUp()
     {
         parent::setUp();
-        $this->viewHelper = $this->getAccessibleMock(RadioViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValueAttribute', 'isObjectAccessorMode', 'getPropertyValue', 'registerFieldNameForFormTokenGeneration'));
+        $this->viewHelper = new RadioViewHelper();
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
-        $this->viewHelper->initializeArguments();
     }
 
     /**
      * @test
      */
-    public function renderCorrectlySetsTagNameAndDefaultAttributes()
+    public function renderSetsTagNameAndDefaultAttributes()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'name' => 'foo',
+            ]
+        );
+        $expectedResult = '<input type="radio" name="foo" value="" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 
     /**
@@ -61,21 +56,16 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
      */
     public function renderSetsCheckedAttributeIfSpecified()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-        $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render(true);
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'name' => 'foo',
+                'checked' => true,
+            ]
+        );
+        $expectedResult = '<input type="radio" name="foo" value="" checked="checked" />';
+        $actualResult = $this->viewHelper->initializeArgumentsAndRender();
+        $this->assertEquals($expectedResult, $actualResult);
     }
 
     /**
@@ -83,22 +73,24 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
      */
     public function renderIgnoresBoundPropertyIfCheckedIsSet()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->expects($this->never())->method('isObjectAccessorMode')->will($this->returnValue(true));
-        $this->viewHelper->expects($this->never())->method('getPropertyValue')->will($this->returnValue(true));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render(true);
-        $this->viewHelper->render(false);
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+                'checked' => true
+            ]
+        );
+        $formObject = new \stdClass();
+        $formObject->someProperty = false;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains('<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" checked="checked" />',
+            $result);
     }
 
     /**
@@ -106,23 +98,26 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
      */
     public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeBoolean()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-        $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(true));
-        $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(true));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = true;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" checked="checked" />',
+            $result
+        );
     }
 
     /**
@@ -130,54 +125,199 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
      */
     public function renderDoesNotAppendSquareBracketsToNameAttributeIfBoundToAPropertyOfTypeArray()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(true));
-        $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(array()));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = [];
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
+            $result
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function renderSetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeString()
+    {
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = '';
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
+            $result
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function renderDoesNotSetsCheckedAttributeIfBoundPropertyIsNull()
+    {
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = null;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
+            $result
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function renderSetsCheckedAttributeForListOfObjects()
+    {
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 2,
+                'property' => 'someProperty',
+            ]
+        );
+
+        $property1 = new \stdClass();
+        $property2 = new \stdClass();
+        $property3 = new \stdClass();
+
+        $persistenceManager = $this->prophesize(PersistenceManager::class);
+        $persistenceManager->getIdentifierByObject($property1)->willReturn(1);
+        $persistenceManager->getIdentifierByObject($property2)->willReturn(2);
+        $persistenceManager->getIdentifierByObject($property3)->willReturn(3);
+        $this->viewHelper->injectPersistenceManager($persistenceManager->reveal());
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = [$property1, $property2, $property3];
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithoutMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="2" />',
+            $result
+        );
     }
 
     /**
      * @test
      */
-    public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeString()
+    public function renderCallSetsErrorClassAttribute()
     {
-        $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
-            ->setMethods(array('setTagName', 'addAttribute'))
-            ->getMock();
-        $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'radio');
-        $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
-        $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
-        $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
-        $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
-
-        $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-        $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
-        $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(true));
-        $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue('bar'));
-        $this->viewHelper->_set('tag', $mockTagBuilder);
-
-        $this->viewHelper->initialize();
-        $this->viewHelper->render();
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+                'errorClass' => 'error',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = null;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" class="error" />',
+            $result
+        );
     }
 
     /**
      * @test
      */
-    public function renderCallsSetErrorClassAttribute()
+    public function renderCallSetsStandardErrorClassAttributeIfNonIsSpecified()
     {
-        $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
-        $this->viewHelper->render();
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = null;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" class="f3-form-error" />',
+            $result
+        );
+    }
+
+    /**
+     * @test
+     */
+    public function renderCallExtendsClassAttributeWithErrorClass()
+    {
+        $this->setArgumentsUnderTest(
+            $this->viewHelper,
+            [
+                'value' => 'foo',
+                'property' => 'someProperty',
+                'class' => 'css_class'
+            ]
+        );
+
+        $formObject = new \stdClass();
+        $formObject->someProperty = null;
+
+        $this->stubVariableContainer($formObject);
+        $this->stubRequestWithMappingErrors();
+
+        $result = $this->viewHelper->initializeArgumentsAndRender();
+
+        $this->assertContains(
+            '<input class="css_class f3-form-error" type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
+            $result
+        );
     }
 }
index 064288c..0111455 100644 (file)
@@ -13,7 +13,9 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use Prophecy\Argument;
 use Prophecy\Prophecy\ObjectProphecy;
+use TYPO3\CMS\Extbase\Error\Result;
 use TYPO3\CMS\Extbase\Reflection\ReflectionService;
 use TYPO3\CMS\Fluid\Core\Variables\CmsVariableProvider;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
@@ -138,4 +140,52 @@ abstract class ViewHelperBaseTestcase extends \TYPO3\CMS\Core\Tests\UnitTestCase
         }
         $viewHelper->setArguments($arguments);
     }
+
+    /**
+     * Helper function for a valid mapping result
+     */
+    protected function stubRequestWithoutMappingErrors()
+    {
+        $this->request->getOriginalRequest()->willReturn(null);
+        $this->request->getArguments()->willReturn([]);
+        $result = $this->prophesize(Result::class);
+        $result->forProperty('objectName')->willReturn($result->reveal());
+        $result->forProperty('someProperty')->willReturn($result->reveal());
+        $result->hasErrors()->willReturn(false);
+        $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
+    }
+
+    /**
+     * Helper function for a mapping result with errors
+     */
+    protected function stubRequestWithMappingErrors()
+    {
+        $this->request->getOriginalRequest()->willReturn(null);
+        $this->request->getArguments()->willReturn([]);
+        $result = $this->prophesize(Result::class);
+        $result->forProperty('objectName')->willReturn($result->reveal());
+        $result->forProperty('someProperty')->willReturn($result->reveal());
+        $result->hasErrors()->willReturn(true);
+        $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
+    }
+
+    /**
+     * Helper function for the bound property
+     *
+     * @param $formObject
+     */
+    protected function stubVariableContainer($formObject)
+    {
+        $this->viewHelperVariableContainer->exists(Argument::cetera())->willReturn(true);
+        $this->viewHelperVariableContainer->get(Argument::any(),
+            'formObjectName')->willReturn('objectName');
+        $this->viewHelperVariableContainer->get(Argument::any(),
+            'fieldNamePrefix')->willReturn('fieldPrefix');
+        $this->viewHelperVariableContainer->get(Argument::any(), 'formFieldNames')->willReturn([]);
+        $this->viewHelperVariableContainer->get(Argument::any(),
+            'formObject')->willReturn($formObject);
+        $this->viewHelperVariableContainer->get(Argument::any(),
+            'renderedHiddenFields')->willReturn([]);
+        $this->viewHelperVariableContainer->addOrUpdate(Argument::cetera())->willReturn(null);
+    }
 }