[FEATURE] Fluid (ViewHelpers): Backported checkbox & radio form viewHelpers from...
authorBastian Waidelich <bastian@typo3.org>
Mon, 31 Aug 2009 19:10:20 +0000 (19:10 +0000)
committerBastian Waidelich <bastian@typo3.org>
Mon, 31 Aug 2009 19:10:20 +0000 (19:10 +0000)
[-BUGFIX] Fluid (ViewHelpers): Removed unused "options"-argument from formViewHelper
[+FEATURE] Fluid (ViewHelpers): Added "actionUri"-argument to formViewHelper which allows to explicitly set the forms action attribute
[~TASK] Fluid (ViewHelpers): Adapted viewHelpers to latest changes of UriBuilder (Extbase revision 1179)
[~BUGFIX] Fluid (ViewHelpers): SubmitViewHelper now correctly extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper
[-TASK] Fluid (Tests): Removed obsolete file ViewHelperBaseTestcase_testcase.php

14 files changed:
typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/ActionViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/PageViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ActionViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/PageViewHelper.php
typo3/sysext/fluid/Tests/ViewHelpers/BaseViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/Form/CheckboxViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/ViewHelpers/Form/RadioViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/ViewHelpers/FormViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/ViewHelperBaseTestcase.php
typo3/sysext/fluid/Tests/ViewHelpers/ViewHelperBaseTestcase_testcase.php [deleted file]

diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php
new file mode 100644 (file)
index 0000000..bd99f16
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View Helper which creates a simple checkbox (<input type="checkbox">).
+ *
+ * = Examples =
+ *
+ * <code title="Example">
+ * <f:form.checkbox name="myCheckBox" value="someValue" />
+ * </code>
+ *
+ * Output:
+ * <input type="checkbox" name="myCheckBox" value="someValue" />
+ *
+ * <code title="Preselect">
+ * <f:form.checkbox name="myCheckBox" value="someValue" checked="{object.value} == 5" />
+ * </code>
+ *
+ * Output:
+ * <input type="checkbox" name="myCheckBox" value="someValue" checked="checked" />
+ * (depending on $object)
+ *
+ * <code title="Bind to object property">
+ * <f:form.checkbox property="interests" value="TYPO3" />
+ * </code>
+ *
+ * Output:
+ * <input type="checkbox" name="user[interests][]" value="TYPO3" checked="checked" />
+ * (depending on property "interests")
+ *
+ * @version $Id$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'input';
+
+       /**
+        * Initialize the arguments.
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       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('value', 'string', 'Value of input tag. Required for checkboxes', TRUE);
+               $this->registerUniversalTagAttributes();
+       }
+
+       /**
+        * Renders the checkbox.
+        *
+        * @param boolean $checked Specifies that the input element should be preselected
+        *
+        * @return string
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($checked = NULL) {
+               $this->tag->addAttribute('type', 'checkbox');
+
+               $nameAttribute = $this->getName();
+               $valueAttribute = $this->getValue();
+               if ($checked === NULL && $this->isObjectAccessorMode()) {
+                       $propertyValue = $this->getPropertyValue();
+                       if (is_bool($propertyValue)) {
+                               $checked = $propertyValue === (boolean)$valueAttribute;
+                       } elseif (is_array($propertyValue)) {
+                               $checked = in_array($valueAttribute, $propertyValue);
+                               $nameAttribute .= '[]';
+                       } else {
+                               throw new Tx_Fluid_Core_ViewHelper_Exception('Checkbox viewhelpers can only be bound to properties of type boolean or array. Property "' . $this->arguments['property'] . '" is of type "' . (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)) . '".' , 1248261038);
+                       }
+               }
+
+               $this->tag->addAttribute('name', $nameAttribute);
+               $this->tag->addAttribute('value', $valueAttribute);
+               if ($checked) {
+                       $this->tag->addAttribute('checked', 'checked');
+               }
+
+               $this->setErrorClassAttribute();
+
+               return $this->tag->render();
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php
new file mode 100644 (file)
index 0000000..f737a9a
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View Helper which creates a simple radio button (<input type="radio">).
+ *
+ * = Examples =
+ *
+ * <code title="Example">
+ * <f:form.radio name="myRadioButton" value="someValue" />
+ * </code>
+ *
+ * Output:
+ * <input type="radio" name="myRadioButton" value="someValue" />
+ *
+ * <code title="Preselect">
+ * <f:form.radio name="myRadioButton" value="someValue" checked="{object.value} == 5" />
+ * </code>
+ *
+ * Output:
+ * <input type="radio" name="myRadioButton" value="someValue" checked="checked" />
+ * (depending on $object)
+ *
+ * <code title="Bind to object property">
+ * <f:form.radio property="newsletter" value="1" /> yes
+ * <f:form.radio property="newsletter" value="0" /> no
+ * </code>
+ *
+ * Output:
+ * <input type="radio" name="user[newsletter]" value="1" checked="checked" /> yes
+ * <input type="radio" name="user[newsletter]" value="0" /> no
+ * (depending on property "newsletter")
+ *
+ * @version $Id$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Form_RadioViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'input';
+
+       /**
+        * Initialize the arguments.
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       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('value', 'string', 'Value of input tag. Required for radio buttons', TRUE);
+               $this->registerUniversalTagAttributes();
+       }
+
+       /**
+        * Renders the checkbox.
+        *
+        * @param boolean $checked Specifies that the input element should be preselected
+        *
+        * @return string
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($checked = NULL) {
+               $this->tag->addAttribute('type', 'radio');
+
+               $nameAttribute = $this->getName();
+               $valueAttribute = $this->getValue();
+               if ($checked === NULL && $this->isObjectAccessorMode()) {
+                       $propertyValue = $this->getPropertyValue();
+                       // no type-safe comparisation by intention
+                       $checked = $propertyValue == $valueAttribute;
+               }
+
+               $this->tag->addAttribute('name', $nameAttribute);
+               $this->tag->addAttribute('value', $valueAttribute);
+               if ($checked) {
+                       $this->tag->addAttribute('checked', 'checked');
+               }
+
+               $this->setErrorClassAttribute();
+
+               return $this->tag->render();
+       }
+}
+
+?>
\ No newline at end of file
index 650baad..f37b62d 100644 (file)
   * Output:
  * <input type="submit" name="mySubmit" value="Send Mail" />
  *
- * @version $Id: SubmitViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: SubmitViewHelper.php 3109 2009-08-31 17:22:46Z bwaidelich $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class Tx_Fluid_ViewHelpers_Form_SubmitViewHelper extends Tx_Fluid_Core_ViewHelper_TagBasedViewHelper {
+class Tx_Fluid_ViewHelpers_Form_SubmitViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
 
        /**
         * @var string
index 51fead9..4ca02bd 100644 (file)
@@ -90,19 +90,18 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
         * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
         * @param string $pluginName Target plugin. If empty, the current plugin name is used
         * @param integer $pageUid Target page uid
-        * @param array $options typolink options
         * @param mixed $object Object to use for the form. Use in conjunction with the "property" attribute on the sub tags
         * @param integer $pageType Target page type
         * @param string $fieldNamePrefix Prefix that will be added to all field names within this form. If not set the prefix will be tx_yourExtension_plugin
+        * @param string $actionUri can be used to overwrite the "action" attribute of the form tag
         * @return string rendered form
         */
-       public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, array $options = array(), $object = NULL, $pageType = 0, $prefix = NULL) {
+       public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $object = NULL, $pageType = 0, $fieldNamePrefix = NULL, $actionUri = NULL) {
                if ($pageUid === NULL) {
                        $pageUid = $GLOBALS['TSFE']->id;
                }
-               $URIBuilder = $this->controllerContext->getURIBuilder();
-               $formActionUrl = $URIBuilder->URIFor($pageUid, $action, $arguments, $controller, $extensionName, $pluginName, $options, $pageType);
-               $this->tag->addAttribute('action', $formActionUrl);
+
+               $this->setFormActionUri();
 
                if (strtolower($this->arguments['method']) === 'get') {
                        $this->tag->addAttribute('method', 'get');
@@ -127,6 +126,25 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
        }
 
        /**
+        * Sets the "action" attribute of the form tag
+        *
+        * @return void
+        */
+       protected function setFormActionUri() {
+               if ($this->arguments->hasArgument('actionUri')) {
+                       $formActionUri = $this->arguments['actionUri'];
+               } else {
+                       $uriBuilder = $this->controllerContext->getUriBuilder();
+                       $uriBuilder->reset();
+                       $uriBuilder
+                               ->setTargetPageUid($this->arguments['pageUid'])
+                               ->setTargetPageType($this->arguments['pageType']);
+                       $formActionUri = $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], $this->arguments['controller'], $this->arguments['extensionName'], $this->arguments['pluginName']);
+               }
+               $this->tag->addAttribute('action', $formActionUri);
+       }
+
+       /**
         * Renders a hidden form field containing the technical identity of the given object.
         *
         * @return string A hidden field containing the Identity (UUID in FLOW3, uid in Extbase) of the given object or NULL if the object is unknown to the persistence framework
index 4c56575..88f9864 100644 (file)
@@ -65,13 +65,26 @@ class Tx_Fluid_ViewHelpers_Link_ActionViewHelper extends Tx_Fluid_Core_ViewHelpe
         * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
         * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
         * @param boolean $absolute If set, the URI of the rendered link is absolute
+        * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
+        * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
         * @return string Rendered link
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function render($action, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE) {
-               $URIBuilder = $this->controllerContext->getURIBuilder();
-               $uri = $URIBuilder->URIFor($pageUid, $action, $arguments, $controller, $extensionName, $pluginName, $pageType, $noCache, !$noCacheHash, $section, $linkAccessRestrictedPages, $additionalParams, $absolute);
+       public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+               $uriBuilder
+                       ->setTargetPageUid($pageUid)
+                       ->setTargetPageType($pageType)
+                       ->setNoCache($noCache)
+                       ->setUseCacheHash(!$noCacheHash)
+                       ->setSection($section)
+                       ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
+                       ->setArguments($additionalParams)
+                       ->setCreateAbsoluteUri($absolute)
+                       ->setAddQueryString($addQueryString)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
+               $uri = $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
 
                $this->tag->addAttribute('href', $uri);
                $this->tag->setContent($this->renderChildren());
index 9917286..f102156 100644 (file)
@@ -67,12 +67,27 @@ class Tx_Fluid_ViewHelpers_Link_PageViewHelper extends Tx_Fluid_Core_ViewHelper_
         * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
         * @param string $section the anchor to be added to the URI
         * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
+        * @param boolean $absolute If set, the URI of the rendered link is absolute
+        * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
+        * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
         * @return string Rendered page URI
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function render($pageUid = NULL, array $additionalParams = array(), $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE) {
-               $URIBuilder = $this->controllerContext->getURIBuilder();
-               $uri = $URIBuilder->typolinkURI($pageUid, $additionalParams, $pageType, $noCache, $noCacheHash, $section, $linkAccessRestrictedPages);
+       public function render($pageUid = NULL, array $additionalParams = array(), $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+               $uriBuilder
+                       ->setTargetPageUid($pageUid)
+                       ->setTargetPageType($pageType)
+                       ->setNoCache($noCache)
+                       ->setUseCacheHash(!$noCacheHash)
+                       ->setSection($section)
+                       ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
+                       ->setArguments($additionalParams)
+                       ->setCreateAbsoluteUri($absolute)
+                       ->setAddQueryString($addQueryString)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
+               $uri = $uriBuilder->build();
+
                $this->tag->addAttribute('href', $uri);
                $this->tag->setContent($this->renderChildren());
 
index 8ef7c4b..8180c03 100644 (file)
@@ -52,13 +52,27 @@ class Tx_Fluid_ViewHelpers_Uri_ActionViewHelper extends Tx_Fluid_Core_ViewHelper
         * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
         * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
         * @param boolean $absolute If set, an absolute URI is rendered
+        * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
+        * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
         * @return string Rendered link
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function render($action, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE) {
-               $URIBuilder = $this->controllerContext->getURIBuilder();
-               $uri = $URIBuilder->URIFor($pageUid, $action, $arguments, $controller, $extensionName, $pluginName, $pageType, $noCache, $noCacheHash, $section, $linkAccessRestrictedPages, $additionalParams, $absolute);
+       public function render($action, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+               $uriBuilder
+                       ->setTargetPageUid($pageUid)
+                       ->setTargetPageType($pageType)
+                       ->setNoCache($noCache)
+                       ->setUseCacheHash(!$noCacheHash)
+                       ->setSection($section)
+                       ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
+                       ->setArguments($additionalParams)
+                       ->setCreateAbsoluteUri($absolute)
+                       ->setAddQueryString($addQueryString)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
+               $uri = $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
+
                return $uri;
        }
 }
index 85fafab..b61bb4b 100644 (file)
@@ -50,12 +50,27 @@ class Tx_Fluid_ViewHelpers_Uri_PageViewHelper extends Tx_Fluid_Core_ViewHelper_A
         * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
         * @param string $section the anchor to be added to the URI
         * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
+        * @param boolean $absolute If set, the URI of the rendered link is absolute
+        * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
+        * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
         * @return string Rendered page URI
         * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function render($pageUid = NULL, array $additionalParams = array(), $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE) {
-               $URIBuilder = $this->controllerContext->getURIBuilder();
-               $uri = $URIBuilder->typolinkURI($pageUid, $additionalParams, $pageType, $noCache, $noCacheHash, $section, $linkAccessRestrictedPages);
+       public function render($pageUid = NULL, array $additionalParams = array(), $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $linkAccessRestrictedPages = FALSE, $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array()) {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+               $uriBuilder
+                       ->setTargetPageUid($pageUid)
+                       ->setTargetPageType($pageType)
+                       ->setNoCache($noCache)
+                       ->setUseCacheHash(!$noCacheHash)
+                       ->setSection($section)
+                       ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
+                       ->setArguments($additionalParams)
+                       ->setCreateAbsoluteUri($absolute)
+                       ->setAddQueryString($addQueryString)
+                       ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
+               $uri = $uriBuilder->build();
+
                return $uri;
        }
 }
index 95fd8b9..5aa1bdc 100644 (file)
@@ -22,7 +22,7 @@
 
 require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
 /**
- * @version $Id: BaseViewHelperTest.php 2813 2009-07-16 14:02:34Z k-fish $
+ * @version $Id: BaseViewHelperTest.php 3109 2009-08-31 17:22:46Z bwaidelich $
  */
 require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
 class Tx_Fluid_ViewHelpers_BaseViewHelperTest_testcase extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
@@ -33,17 +33,14 @@ class Tx_Fluid_ViewHelpers_BaseViewHelperTest_testcase extends Tx_Fluid_ViewHelp
        public function renderTakesBaseURIFromControllerContext() {
                $baseURI = 'http://typo3.org/';
 
-               $request = $this->getMock('Tx_Extbase_MVC_Web_Request');
-               $request->expects($this->any())->method('getBaseURI')->will($this->returnValue($baseURI));
+               $this->request->expects($this->any())->method('getBaseURI')->will($this->returnValue($baseURI));
 
-               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($request));
-
-               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_BaseViewHelper'), array('dummy'), array(), '', FALSE);
+               $viewHelper = new Tx_Fluid_ViewHelpers_BaseViewHelper();
                $this->injectDependenciesIntoViewHelper($viewHelper);
 
-               $expected = '<base href="http://typo3.org/"></base>';
-               $actual = $viewHelper->render();
-               $this->assertSame($expected, $actual);
+               $expectedResult = '<base href="' . $baseURI . '"></base>';
+               $actualResult = $viewHelper->render();
+               $this->assertSame($expectedResult, $actualResult);
        }
 }
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/ViewHelpers/Form/CheckboxViewHelperTest_testcase.php b/typo3/sysext/fluid/Tests/ViewHelpers/Form/CheckboxViewHelperTest_testcase.php
new file mode 100644 (file)
index 0000000..208517d
--- /dev/null
@@ -0,0 +1,186 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
+
+/**
+ * Test for the "Checkbox" Form view helper
+ *
+ * @version $Id$
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
+ */
+require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
+class Tx_Fluid_ViewHelpers_Form_CheckboxViewHelperTest_testcase extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+
+       /**
+        * var Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper
+        */
+       protected $viewHelper;
+
+       public function setUp() {
+               parent::setUp();
+               $this->viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper'), array('setErrorClassAttribute', 'getName', 'getValue', 'isObjectAccessorMode', 'getPropertyValue'));
+               $this->injectDependenciesIntoViewHelper($this->viewHelper);
+               $this->viewHelper->initializeArguments();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsTagNameAndDefaultAttributes() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $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('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderSetsCheckedAttributeIfSpecified() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', '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('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render(TRUE);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderIgnoresBoundPropertyIfCheckedIsSet() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render(TRUE);
+               $this->viewHelper->render(FALSE);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeBoolean() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', '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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderAppendsSquareBracketsToNameAttributeIfBoundToAPropertyOfTypeArray() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeArray() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox');
+               $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', '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('getValue')->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('foo', 'bar', 'baz')));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @expectedException Tx_Fluid_Core_ViewHelper_Exception
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function bindingObjectsToACheckboxThatAreNotOfTypeBooleanOrArrayThrowsException() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+
+               $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
+               $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(new stdClass()));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCallsSetErrorClassAttribute() {
+               $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
+               $this->viewHelper->render();
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Tests/ViewHelpers/Form/RadioViewHelperTest_testcase.php b/typo3/sysext/fluid/Tests/ViewHelpers/Form/RadioViewHelperTest_testcase.php
new file mode 100644 (file)
index 0000000..a12a847
--- /dev/null
@@ -0,0 +1,170 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
+
+/**
+ * Test for the "Radio" Form view helper
+ *
+ * @version $Id$
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
+ */
+require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
+class Tx_Fluid_ViewHelpers_Form_RadioViewHelperTest_testcase extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+
+       /**
+        * var Tx_Fluid_ViewHelpers_Form_RadioViewHelper
+        */
+       protected $viewHelper;
+
+       public function setUp() {
+               parent::setUp();
+               $this->viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_Form_RadioViewHelper'), array('setErrorClassAttribute', 'getName', 'getValue', 'isObjectAccessorMode', 'getPropertyValue'));
+               $this->injectDependenciesIntoViewHelper($this->viewHelper);
+               $this->viewHelper->initializeArguments();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsTagNameAndDefaultAttributes() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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');
+               $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('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderSetsCheckedAttributeIfSpecified() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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');
+               $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('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render(TRUE);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderIgnoresBoundPropertyIfCheckedIsSet() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render(TRUE);
+               $this->viewHelper->render(FALSE);
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeBoolean() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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');
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderDoesNotAppendSquareBracketsToNameAttributeIfBoundToAPropertyOfTypeArray() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCorrectlySetsCheckedAttributeIfCheckboxIsBoundToAPropertyOfTypeString() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('setTagName', 'addAttribute'));
+               $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');
+               $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('getValue')->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->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderCallsSetErrorClassAttribute() {
+               $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
+               $this->viewHelper->render();
+       }
+}
+
+?>
\ No newline at end of file
index 78acd60..5271cb7 100644 (file)
@@ -259,11 +259,69 @@ class Tx_Fluid_ViewHelpers_FormViewHelperTest_testcase extends Tx_Fluid_ViewHelp
                $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($viewHelper);
 
-               $viewHelper->setArguments(new Tx_Fluid_Core_ViewHelper_Arguments(array()));
-
                $this->viewHelperVariableContainer->expects($this->once())->method('add')->with('Tx_Fluid_ViewHelpers_FormViewHelper', 'fieldNamePrefix', $expectedPrefix);
                $this->viewHelperVariableContainer->expects($this->once())->method('remove')->with('Tx_Fluid_ViewHelpers_FormViewHelper', 'fieldNamePrefix');
                $viewHelper->render();
        }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function setFormActionUriUsesUriBuilderToSetActionAttribute() {
+               $this->uriBuilder->expects($this->once())->method('reset')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->once())->method('setTargetPageUid')->with(123)->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->once())->method('setTargetPageType')->with(2)->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->once())->method('uriFor')->with('someAction', array('foo' => 'bar'), 'someController', 'someExtensionName', 'somePluginName')->will($this->returnValue('someUri'));
+
+               $this->tagBuilder->expects($this->once())->method('addAttribute')->with('action', 'someUri');
+
+               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields'), array(), '', FALSE);
+               $this->injectDependenciesIntoViewHelper($viewHelper);
+
+               $viewHelper->setArguments(
+                       new Tx_Fluid_Core_ViewHelper_Arguments(
+                               array(
+                                       'pageUid' => 123,
+                                       'pageType' => 2,
+                                       'action' => 'someAction',
+                                       'arguments' => array('foo' => 'bar'),
+                                       'controller' => 'someController',
+                                       'extensionName' => 'someExtensionName',
+                                       'pluginName' => 'somePluginName',
+                               )
+                       )
+               );
+
+               $viewHelper->_call('setFormActionUri');
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function setFormActionUriRespectsActionUriArgument() {
+               $this->tagBuilder->expects($this->once())->method('addAttribute')->with('action', 'someOverwrittenUri');
+
+               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields'), array(), '', FALSE);
+               $this->injectDependenciesIntoViewHelper($viewHelper);
+
+               $viewHelper->setArguments(
+                       new Tx_Fluid_Core_ViewHelper_Arguments(
+                               array(
+                                       'pageUid' => 123,
+                                       'pageType' => 2,
+                                       'action' => 'someAction',
+                                       'arguments' => array('foo' => 'bar'),
+                                       'controller' => 'someController',
+                                       'extensionName' => 'someExtensionName',
+                                       'pluginName' => 'somePluginName',
+                                       'actionUri' => 'someOverwrittenUri',
+                               )
+                       )
+               );
+
+               $viewHelper->_call('setFormActionUri');
+       }
 }
 ?>
\ No newline at end of file
index bf3d040..cded43b 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id: ViewHelperBaseTestcase.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: ViewHelperBaseTestcase.php 3109 2009-08-31 17:22:46Z bwaidelich $
  */
 abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Base_testcase {
 
@@ -36,7 +36,7 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
        protected $templateVariableContainer;
 
        /**
-        * @var \Tx_Extbase_MVC_Web_Routing_URIBuilder
+        * @var \Tx_Extbase_MVC_Web_Routing_UriBuilder
         */
        protected $uriBuilder;
 
@@ -56,15 +56,32 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
        protected $arguments;
 
        /**
+        * @var \Tx_Extbase_MVC_Web_Request
+        */
+       protected $request;
+
+       /**
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function setUp() {
                $this->viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
                $this->templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
-               $this->uriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_URIBuilder');
+               $this->uriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_UriBuilder');
+               $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
+               $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
+               $this->request = $this->getMock('Tx_Extbase_MVC_Web_Request');
                $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext');
-               $this->controllerContext->expects($this->any())->method('getURIBuilder')->will($this->returnValue($this->uriBuilder));
+               $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
+               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
                $this->tagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder');
                $this->arguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
        }
diff --git a/typo3/sysext/fluid/Tests/ViewHelpers/ViewHelperBaseTestcase_testcase.php b/typo3/sysext/fluid/Tests/ViewHelpers/ViewHelperBaseTestcase_testcase.php
deleted file mode 100644 (file)
index 1b4a76c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-/*                                                                        *
- * This script belongs to the FLOW3 package "Fluid".                      *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU General Public License as published by the Free   *
- * Software Foundation, either version 3 of the License, or (at your      *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
- * Public License for more details.                                       *
- *                                                                        *
- * You should have received a copy of the GNU General Public License      *
- * along with the script.                                                 *
- * If not, see http://www.gnu.org/licenses/gpl.html                       *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * @version $Id$
- */
-require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
-abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase_testcase extends Tx_Extbase_Base_testcase {
-
-       /**
-        * @var Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
-        */
-       protected $viewHelperVariableContainer;
-
-       /**
-        * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
-        */
-       protected $templateVariableContainer;
-
-       /**
-        * @var Tx_Fluid_MVC_Web_Routing_URIBuilder
-        */
-       protected $uriBuilder;
-
-       /**
-        * @var \Tx_Extbase_MVC_Controller_ControllerContext
-        */
-       protected $controllerContext;
-
-       /**
-        * @var Tx_Fluid_Core_ViewHelper_TagBuilder
-        */
-       protected $tagBuilder;
-
-       /**
-        * @var Tx_Fluid_Core_ViewHelper_Arguments
-        */
-       protected $arguments;
-
-       /**
-        * @var \Tx_Extbase_MVC_Request
-        */
-       protected $request;
-
-       /**
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       public function setUp() {
-               $this->viewHelperVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
-               $this->templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
-               $this->uriBuilder = $this->getMock('Tx_Fluid_MVC_Web_Routing_URIBuilder');
-               $this->request = $this->getMock('Tx_Extbase_MVC_Request');
-               $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext');
-               $this->controllerContext->expects($this->any())->method('getURIBuilder')->will($this->returnValue($this->uriBuilder));
-               $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
-               $this->tagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder');
-               $this->arguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
-       }
-
-       /**
-        * @param Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function injectDependenciesIntoViewHelper(Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper) {
-               $viewHelper->setViewHelperVariableContainer($this->viewHelperVariableContainer);
-               $viewHelper->setTemplateVariableContainer($this->templateVariableContainer);
-               $viewHelper->setControllerContext($this->controllerContext);
-               $viewHelper->setArguments($this->arguments);
-               if ($viewHelper instanceof Tx_Fluid_Core_ViewHelper_TagBasedViewHelper) {
-                       $viewHelper->injectTagBuilder($this->tagBuilder);
-               }
-       }
-}
-?>