[+FEATURE] Fluid (ViewHelpers): Added a PaddingViewHelper
authorSebastian Kurfürst <sebastian@typo3.org>
Wed, 16 Sep 2009 10:06:17 +0000 (10:06 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Wed, 16 Sep 2009 10:06:17 +0000 (10:06 +0000)
[+FEATURE] Fluid (ViewHelpers): Added a RenderFlashMessages ViewHelper
[TASK] Fluid (Core): Added a PaddingViewHelper
[TASK] Fluid (Core): Added an exception if ViewHelpers declare an argument multiple times.

25 files changed:
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBasedViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/ErrorsViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextboxViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/RenderFlashMessagesViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Core/TagBasedViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/Core/TagBuilderTest_testcase.php
typo3/sysext/fluid/Tests/Core/TemplateParserTest_testcase.php
typo3/sysext/fluid/Tests/Core/ViewHelper/AbstractViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/Form/AbstractFormFieldViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/Form/AbstractFormViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/Form/HiddenViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/FormViewHelperTest_testcase.php
typo3/sysext/fluid/Tests/ViewHelpers/ViewHelperBaseTestcase.php

index 938cacc..c1701da 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * The abstract base class for all view helpers.
  *
- * @version $Id: AbstractViewHelper.php 2902 2009-07-27 21:41:23Z sebastian $
+ * @version $Id: AbstractViewHelper.php 3178 2009-09-16 08:13:30Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
@@ -172,6 +172,9 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
         * @api
         */
        protected function registerArgument($name, $type, $description, $required = FALSE, $defaultValue = NULL) {
+               if (array_key_exists($name, $this->argumentDefinitions)) {
+                       throw new Tx_Fluid_Core_ViewHelper_Exception('Argument "' . $name . '" has already been defined, thus it should not be defined again.', 1253036401);
+               }
                $this->argumentDefinitions[$name] = new Tx_Fluid_Core_ViewHelper_ArgumentDefinition($name, $type, $description, $required, $defaultValue);
                return $this;
        }
@@ -240,11 +243,14 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
                if (count($methodParameters) === 0) {
                        return;
                }
-               $methodTags = $this->reflectionService->getMethodTagsValues(get_class($this), 'render');
 
-               $paramAnnotations = array();
-               if (isset($methodTags['param'])) {
-                       $paramAnnotations = $methodTags['param'];
+               if (Tx_Fluid_Fluid::$debugMode) {
+                       $methodTags = $this->reflectionService->getMethodTagsValues(get_class($this), 'render');
+
+                       $paramAnnotations = array();
+                       if (isset($methodTags['param'])) {
+                               $paramAnnotations = $methodTags['param'];
+                       }
                }
 
                $i = 0;
@@ -260,7 +266,7 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_C
                        }
 
                        $description = '';
-                       if (isset($paramAnnotations[$i])) {
+                       if (Tx_Fluid_Fluid::$debugMode && isset($paramAnnotations[$i])) {
                                $explodedAnnotation = explode(' ', $paramAnnotations[$i]);
                                array_shift($explodedAnnotation);
                                array_shift($explodedAnnotation);
index c637de5..d99510c 100644 (file)
@@ -25,7 +25,7 @@
  * Sould be used as the base class for all view helpers which output simple tags, as it provides some
  * convenience methods to register default attributes, ...
  *
- * @version $Id: TagBasedViewHelper.php 2813 2009-07-16 14:02:34Z k-fish $
+ * @version $Id: TagBasedViewHelper.php 3119 2009-09-03 19:27:00Z bwaidelich $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
@@ -85,6 +85,7 @@ abstract class Tx_Fluid_Core_ViewHelper_TagBasedViewHelper extends Tx_Fluid_Core
         */
        public function initialize() {
                parent::initialize();
+               $this->tag->reset();
                $this->tag->setTagName($this->tagName);
                if (is_array($this->arguments['additionalAttributes'])) {
                        $this->tag->addAttributes($this->arguments['additionalAttributes']);
index b26bc28..50c6ea9 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Tag builder. Can be easily accessed in TagBasedViewHelper
  *
- * @version $Id: TagBuilder.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: TagBuilder.php 3119 2009-09-03 19:27:00Z bwaidelich $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
@@ -189,6 +189,20 @@ class Tx_Fluid_Core_ViewHelper_TagBuilder {
        }
 
        /**
+        * Resets the TagBuilder by setting all members to their default value
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function reset() {
+               $this->tagName = '';
+               $this->content = '';
+               $this->attributes = array();
+               $this->forceClosingTag = FALSE;
+       }
+
+       /**
         * Renders and returns the tag
         *
         * @return void
index d83ac4b..832f085 100644 (file)
@@ -26,7 +26,7 @@
  * If you set the "property" attribute to the name of the property to resolve from the object, this class will
  * automatically set the name and value of a form element.
  *
- * @version $Id$
+ * @version $Id: AbstractFormFieldViewHelper.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
  */
@@ -36,7 +36,7 @@ abstract class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper extends Tx_
         * Initialize arguments.
         *
         * @return void
-        * @author Sebastian Kurfrst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @api
         */
        public function initializeArguments() {
@@ -51,7 +51,7 @@ abstract class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper extends Tx_
         * Either returns arguments['name'], or the correct name for Object Access.
         *
         * @return string Name
-        * @author Sebastian Kurfrst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Robert Lemke <robert@typo3.org>
         * @author Karsten Dambekalns <karsten@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
@@ -81,7 +81,7 @@ abstract class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper extends Tx_
         * Either returns arguments['value'], or the correct value for Object Access.
         *
         * @return mixed Value
-        * @author Sebastian Kurfrst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Robert Lemke <robert@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
@@ -120,7 +120,7 @@ abstract class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper extends Tx_
         * Internal method which checks if we should evaluate a domain object or just output arguments['name'] and arguments['value']
         *
         * @return boolean TRUE if we should evaluate the domain object, FALSE otherwise.
-        * @author Sebastian Kurfrst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        protected function isObjectAccessorMode() {
                return $this->arguments->hasArgument('property')
@@ -180,4 +180,4 @@ abstract class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper extends Tx_
        }
 }
 
-?>
+?>
\ No newline at end of file
index 3b1cee4..a6f5421 100644 (file)
@@ -26,7 +26,7 @@
  * If you set the "property" attribute to the name of the property to resolve from the object, this class will
  * automatically set the name and value of a form element.
  *
- * @version $Id: AbstractFormViewHelper.php 2968 2009-08-03 10:45:13Z sebastian $
+ * @version $Id: AbstractFormViewHelper.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
  */
index bd99f16..04ba728 100644 (file)
@@ -70,7 +70,7 @@ class Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper extends Tx_Fluid_ViewHelpers_
                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->registerArgument('value', 'string', 'Value of input tag. Required for checkboxes', TRUE);
                $this->registerUniversalTagAttributes();
        }
 
index bf68b78..bc9c6d9 100644 (file)
@@ -38,7 +38,7 @@
  *   <li>1234567890: Validation errors for argument "newBlog"</li>
  * </ul>
  *
- * @version $Id$
+ * @version $Id: ForViewHelper.php 2378 2009-05-25 20:47:00Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
@@ -87,4 +87,4 @@ class Tx_Fluid_ViewHelpers_Form_ErrorsViewHelper extends Tx_Fluid_Core_ViewHelpe
        }
 }
 
-?>
+?>
\ No newline at end of file
index e9b0406..a711025 100644 (file)
@@ -35,7 +35,7 @@
  * You can also use the "property" attribute if you have bound an object to the form.
  * See <f:form> for more documentation.
  *
- * @version $Id: HiddenViewHelper.php 2813 2009-07-16 14:02:34Z k-fish $
+ * @version $Id: HiddenViewHelper.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
  */
index f737a9a..1659bde 100644 (file)
@@ -72,7 +72,7 @@ class Tx_Fluid_ViewHelpers_Form_RadioViewHelper extends Tx_Fluid_ViewHelpers_For
                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->registerArgument('value', 'string', 'Value of input tag. Required for radio buttons', TRUE);
                $this->registerUniversalTagAttributes();
        }
 
index b983165..29fc6e1 100644 (file)
@@ -46,7 +46,7 @@
  *
  * If you want to output domain objects, you can just pass them as array into the "options" parameter.
  * To define what domain object value should be used as option key, use the "optionValueField" variable. Same goes for optionLabelField.
- * If neither is given, the Identifier (UID) and the __toString() method are tried as fallbacks.
+ * If neither is given, the Identifier (UID/uid) and the __toString() method are tried as fallbacks.
  *
  * If the optionValueField variable is set, the getter named after that value is used to retrieve the option key.
  * If the optionLabelField variable is set, the getter named after that value is used to retrieve the option value.
@@ -60,7 +60,7 @@
  *
  * The "value" property now expects a domain object, and tests for object equivalence.
  *
- * @version $Id: SelectViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: SelectViewHelper.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
  */
index f37b62d..3b2d70f 100644 (file)
@@ -39,7 +39,7 @@
   * Output:
  * <input type="submit" name="mySubmit" value="Send Mail" />
  *
- * @version $Id: SubmitViewHelper.php 3109 2009-08-31 17:22:46Z bwaidelich $
+ * @version $Id: SubmitViewHelper.php 3178 2009-09-16 08:13:30Z sebastian $
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
@@ -66,21 +66,15 @@ class Tx_Fluid_ViewHelpers_Form_SubmitViewHelper extends Tx_Fluid_ViewHelpers_Fo
        /**
         * Renders the submit button.
         *
-        * @param string name Name of submit tag
-        * @param string value Value of submit tag
         * @return string
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         * @api
         */
-       public function render($name = '', $value = '') {
+       public function render() {
                $this->tag->addAttribute('type', 'submit');
-               if ($name !== '') {
-                       $this->tag->addAttribute('name', $name);
-               }
-               if ($value !== '') {
-                       $this->tag->addAttribute('value', $value);
-               }
+               $this->tag->addAttribute('name', $this->getName());
+               $this->tag->addAttribute('value', $this->getValue());
 
                return $this->tag->render();
        }
index 349be55..c134170 100644 (file)
@@ -33,7 +33,7 @@
  * Output:
  * <textarea name="myTextArea">This is shown inside the textarea</textarea>
  *
- * @version $Id: TextareaViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: TextareaViewHelper.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
  */
index 871979f..32403c9 100644 (file)
@@ -32,7 +32,7 @@
  * Output:
  * <input type="text" name="myTextBox" value="default value" />
  *
- * @version $Id: TextboxViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: TextboxViewHelper.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
  */
index 10f5630..650f0fd 100644 (file)
@@ -33,7 +33,7 @@
  * Output:
  * <input type="file" name="file" />
  *
- * @version $Id: UploadViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @version $Id: UploadViewHelper.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
  */
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php
new file mode 100644 (file)
index 0000000..8628ed7
--- /dev/null
@@ -0,0 +1,63 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * Formats a string using PHPs str_pad function.
+ * @See http://www.php.net/manual/en/function.str_pad.php
+ *
+ * = Examples =
+ *
+ * <code title="Defaults">
+ * <f:format.padding padLength="10">TYPO3</f:format.padding>
+ * </code>
+ *
+ * Output:
+ * TYPO3     (note the trailing whitespace)
+ *
+ * <code title="Specify padding string">
+ * <f:format.padding padLength="10" padString="-=">TYPO3</f:format.padding>
+ * </code>
+ *
+ * Output:
+ * TYPO3-=-=-
+ *
+ * @version $Id: PaddingViewHelper.php 3169 2009-09-10 12:52:22Z k-fish $
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Format_PaddingViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * Format the arguments with the given printf format string.
+        *
+        * @param integer $padLength Length of the resulting string. If the value of pad_length is negative or less than the length of the input string, no padding takes place.
+        * @param string $padString The padding string
+        * @return string The formatted value
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($padLength, $padString = ' ') {
+               $string = $this->renderChildren();
+               return str_pad($string, $padLength, $padString);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/RenderFlashMessagesViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/RenderFlashMessagesViewHelper.php
new file mode 100644 (file)
index 0000000..48ca22f
--- /dev/null
@@ -0,0 +1,88 @@
+<?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 renders the flash messages (if there are any) as an unsorted list.
+ *
+ * In case you need custom Flash Message HTML output, please write your own ViewHelper for the moment.
+ *
+ *
+ * = Examples =
+ *
+ * <code title="Simple">
+ * <f:renderFlashMessages />
+ * </code>
+ * Renders an ul-list of flash messages.
+ *
+ * <code title="Output with css class">
+ * <f:renderFlashMessages class="specialClass" />
+ * </code>
+ *
+ * Output:
+ * <ul class="specialClass">
+ *  ...
+ * </ul>
+ *
+ * @version $Id: ForViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_RenderFlashMessagesViewHelper extends Tx_Fluid_Core_ViewHelper_TagBasedViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'ul';
+
+       /**
+        * Initialize arguments
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        * @api
+        */
+       public function initializeArguments() {
+               $this->registerUniversalTagAttributes();
+       }
+
+       /**
+        * Render method.
+        *
+        * @return string rendered Flash Messages, if there are any.
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        * @api
+        */
+       public function render() {
+               $flashMessages = $this->controllerContext->getFlashMessages()->getAllAndFlush();
+               if (count($flashMessages) > 0) {
+                       $tagContent = '';
+                       foreach ($flashMessages as $singleFlashMessage) {
+                               $tagContent .=  '<li>' . htmlspecialchars($singleFlashMessage) . '</li>';
+                       }
+                       $this->tag->setContent($tagContent);
+                       return $this->tag->render();
+               }
+               return '';
+       }
+}
+
+?>
index d655e5c..cd4ccd3 100644 (file)
@@ -27,6 +27,19 @@ class Tx_Fluid_Core_TagBasedViewHelperTest_testcase extends Tx_Extbase_Base_test
        public function setUp() {
                $this->viewHelper = new Tx_Fluid_Core_Fixtures_TestTagBasedViewHelper();
        }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function initializeResetsUnderlyingTagBuilder() {
+               $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('reset'), array(), '', FALSE);
+               $mockTagBuilder->expects($this->once())->method('reset');
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $this->viewHelper->initialize();
+       }
+
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index 472a402..3aeb372 100644 (file)
@@ -101,6 +101,16 @@ class Tx_Fluid_Core_TagBuilderTest_testcase extends Tx_Extbase_Base_testcase {
         * @test
         * @author Bastian Waidelich <bastian@typo3.org>
         */
+       public function contentCanBeRemoved() {
+               $tagBuilder = new Tx_Fluid_Core_ViewHelper_TagBuilder('tag', 'some content');
+               $tagBuilder->setContent(NULL);
+               $this->assertEquals('<tag />', $tagBuilder->render());
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
        public function renderReturnsOpeningAndClosingTagIfNoContentIsSpecifiedButForceClosingTagIsTrue() {
                $tagBuilder = new Tx_Fluid_Core_ViewHelper_TagBuilder('tag');
                $tagBuilder->forceClosingTag(TRUE);
@@ -156,6 +166,25 @@ class Tx_Fluid_Core_TagBuilderTest_testcase extends Tx_Extbase_Base_testcase {
         * @test
         * @author Bastian Waidelich <bastian@typo3.org>
         */
+       public function resetResetsTagBuilder() {
+               $tagBuilder = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_Core_ViewHelper_TagBuilder'), array('dummy'));
+               $tagBuilder->setTagName('tagName');
+               $tagBuilder->setContent('some content');
+               $tagBuilder->forceClosingTag(TRUE);
+               $tagBuilder->addAttribute('attribute1', 'attribute1value');
+               $tagBuilder->addAttribute('attribute2', 'attribute2value');
+               $tagBuilder->reset();
+
+               $this->assertEquals('', $tagBuilder->_get('tagName'));
+               $this->assertEquals('', $tagBuilder->_get('content'));
+               $this->assertEquals(array(), $tagBuilder->_get('attributes'));
+               $this->assertFalse($tagBuilder->_get('forceClosingTag'));
+       }
+
+       /**
+        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
        public function tagNameCanBeOverridden() {
                $tagBuilder = new Tx_Fluid_Core_ViewHelper_TagBuilder('foo');
                $tagBuilder->setTagName('bar');
index 1986761..b77dcdb 100644 (file)
@@ -436,7 +436,7 @@ class Tx_Fluid_Core_TemplateParserTest_testcase extends Tx_Extbase_Base_testcase
                $actual = $this->templateParser->parse($templateSource)->getRootNode();
                $this->assertEquals($expected, $actual, 'Fixture 14 was not parsed correctly.');
        }
-       
+
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index e03918c..9e1bd82 100644 (file)
@@ -18,7 +18,7 @@ include_once(dirname(__FILE__) . '/../Fixtures/TestViewHelper.php');
 /**
  * Testcase for AbstractViewHelper
  *
- * @version $Id: AbstractViewHelperTest.php 2813 2009-07-16 14:02:34Z k-fish $
+ * @version $Id: AbstractViewHelperTest.php 3178 2009-09-16 08:13:30Z sebastian $
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
  */
 require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
@@ -44,6 +44,23 @@ class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest_testcase extends Tx_Extbas
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @expectedException Tx_Fluid_Core_ViewHelper_Exception
+        */
+       public function registeringTheSameArgumentNameAgainThrowsException() {
+               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_Core_ViewHelper_AbstractViewHelper'), array('render'), array(), '', FALSE);
+
+               $name = "shortName";
+               $description = "Example desc";
+               $type = "string";
+               $isRequired = TRUE;
+
+               $viewHelper->_call('registerArgument', $name, $type, $isRequired, $description);
+               $viewHelper->_call('registerArgument', $name, "integer", $isRequired, $description);
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function prepareArgumentsCallsInitializeArguments() {
                $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_Core_ViewHelper_AbstractViewHelper'), array('render', 'initializeArguments'), array(), '', FALSE);
@@ -59,7 +76,9 @@ class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest_testcase extends Tx_Extbas
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function prepareArgumentsRegistersAnnotationBasedArguments() {
+       public function prepareArgumentsRegistersAnnotationBasedArgumentsWithDescriptionIfDebugModeIsEnabled() {
+
+               Tx_Fluid_Fluid::$debugMode = TRUE;
 
                $availableClassNames = array(
                        'Tx_Fluid_Core_Fixtures_TestViewHelper',
@@ -79,7 +98,36 @@ class Tx_Fluid_Core_ViewHelper_AbstractViewHelperTest_testcase extends Tx_Extbas
 
                $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
 
+               Tx_Fluid_Fluid::$debugMode = FALSE;
        }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function prepareArgumentsRegistersAnnotationBasedArgumentsWithoutDescriptionIfDebugModeIsDisabled() {
+
+               Tx_Fluid_Fluid::$debugMode = FALSE;
+
+               $availableClassNames = array(
+                       'Tx_Fluid_Core_Fixtures_TestViewHelper',
+               );
+               $reflectionService = new Tx_Extbase_Reflection_Service();
+               // $reflectionService->setCache($this->getMock('Tx_Fluid_Cache_Frontend_VariableFrontend', array(), array(), '', FALSE));
+               // $reflectionService->initialize($availableClassNames);
+
+               $viewHelper = new Tx_Fluid_Core_Fixtures_TestViewHelper();
+               $viewHelper->injectReflectionService($reflectionService);
+
+               $expected = array(
+                       'param1' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param1', 'integer', '', TRUE, null, TRUE),
+                       'param2' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param2', 'array', '', TRUE, null, TRUE),
+                       'param3' => new Tx_Fluid_Core_ViewHelper_ArgumentDefinition('param3', 'string', '', FALSE, 'default', TRUE),
+               );
+
+               $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
+       }
+
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index 669cf70..96b4e93 100644 (file)
@@ -18,7 +18,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
 /**
  * Test for the Abstract Form view helper
  *
- * @version $Id$
+ * @version $Id: AbstractFormFieldViewHelperTest.php 3109 2009-08-31 17:22:46Z bwaidelich $
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
  */
 require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
@@ -59,13 +59,13 @@ class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelperTest_testcase extends
                $formViewHelper->_set('arguments', $arguments);
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
 
-               $this->assertSame('foo[uid]', $formViewHelper->_call('getName'));
+               $this->assertSame('foo[__identity]', $formViewHelper->_call('getName'));
                $this->assertSame('6f487e40-4483-11de-8a39-0800200c9a66', $formViewHelper->_call('getValue'));
        }
 
        /**
         * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function getNameBuildsNameFromFieldNamePrefixFormNameAndPropertyIfInObjectAccessorMode() {
@@ -125,7 +125,7 @@ class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelperTest_testcase extends
 
        /**
         * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function getValueBuildsValueFromPropertyAndFormObjectIfInObjectAccessorMode() {
@@ -187,7 +187,7 @@ class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelperTest_testcase extends
 
        /**
         * @test
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function isObjectAccessorModeReturnsTrueIfPropertyIsSetAndFormObjectIsGiven() {
                $formViewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper'), array('dummy'), array(), '', FALSE);
@@ -345,4 +345,4 @@ class Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelperTest_testcase extends
        }
 }
 
-?>
+?>
\ No newline at end of file
index 427f057..5293486 100644 (file)
@@ -18,7 +18,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
 /**
  * Test for the Abstract Form view helper
  *
- * @version $Id: AbstractFormViewHelperTest.php 2991 2009-08-06 12:09:58Z robert $
+ * @version $Id: AbstractFormViewHelperTest.php 3109 2009-08-31 17:22:46Z bwaidelich $
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
  */
 require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
index b8ab60a..e33636c 100644 (file)
@@ -18,7 +18,7 @@ require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
 /**
  * Test for the "Hidden" Form view helper
  *
- * @version $Id$
+ * @version $Id: HiddenViewHelperTest.php 3109 2009-08-31 17:22:46Z bwaidelich $
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
  */
 require_once(t3lib_extMgm::extPath('extbase', 'Tests/Base_testcase.php'));
@@ -56,4 +56,4 @@ class Tx_Fluid_ViewHelpers_Form_HiddenViewHelperTest_testcase extends Tx_Fluid_V
        }
 }
 
-?>
+?>
\ No newline at end of file
index 5271cb7..ec2680e 100644 (file)
@@ -40,7 +40,7 @@ class Tx_Fluid_ViewHelpers_FormViewHelperTest_testcase extends Tx_Fluid_ViewHelp
                $object->_set('uid', '123');
                $object->expects($this->once())->method('_isNew')->will($this->returnValue(FALSE));
 
-               $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][uid]" value="123" />' . chr(10);
+               $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][__identity]" value="123" />' . chr(10);
 
                $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('prefixFieldName'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($viewHelper);
@@ -61,7 +61,7 @@ class Tx_Fluid_ViewHelpers_FormViewHelperTest_testcase extends Tx_Fluid_ViewHelp
                $object->expects($this->once())->method('_isNew')->will($this->returnValue(TRUE));
                $object->expects($this->once())->method('_isClone')->will($this->returnValue(TRUE));
 
-               $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][uid]" value="123" />' . chr(10);
+               $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][__identity]" value="123" />' . chr(10);
 
                $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('prefixFieldName'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($viewHelper);
index d618b03..d83493b 100644 (file)
@@ -21,7 +21,7 @@
  *                                                                        */
 
 /**
- * @version $Id: ViewHelperBaseTestcase.php 3109 2009-08-31 17:22:46Z bwaidelich $
+ * @version $Id: ViewHelperBaseTestcase.php 3179 2009-09-16 08:51:02Z sebastian $
  */
 abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Base_testcase {
 
@@ -71,14 +71,15 @@ abstract class Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase extends Tx_Extbase_Ba
                $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->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('setFormat')->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->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));