[-API] Extbase (MVC): Removed enableValidation() and disableValidation() on the Contr...
authorSebastian Kurfürst <sebastian@typo3.org>
Thu, 17 Sep 2009 10:50:35 +0000 (10:50 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Thu, 17 Sep 2009 10:50:35 +0000 (10:50 +0000)
[!!!][+BUGFIX] Extbase (MVC): Now, in case people do not specify an @param annotation, they will get an exception instead of Text being used.
[+BUGFIX] Extbsee (MVC): Cleaned up validator registration in ActionController. Now, @dontvalidate annotations only disable the model-based validators.
[+BUGFIX] Extbase (Validation): Cleaned up ValidatorResolver. Now, Validators which check the data type from the @param annotation are also added to the validator chain.
[!!!][+BUGFIX] Extbase (Validation): @param string is now validated as string, and not anymore as Text. This fixes numerous bug reports in Fluid.

typo3/sysext/extbase/Classes/MVC/Controller/AbstractController.php
typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php
typo3/sysext/extbase/Classes/MVC/Controller/Argument.php
typo3/sysext/extbase/Classes/MVC/Controller/ArgumentsValidator.php
typo3/sysext/extbase/Classes/Validation/Exception/InvalidValidationConfiguration.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
typo3/sysext/extbase/Tests/MVC/Controller/ActionController_testcase.php
typo3/sysext/extbase/Tests/Validation/ValidatorResolver_testcase.php

index 7c371ae..a5364ad 100755 (executable)
@@ -364,6 +364,7 @@ abstract class Tx_Extbase_MVC_Controller_AbstractController implements Tx_Extbas
 
                $validator = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_ArgumentsValidator');
                $this->propertyMapper->mapAndValidate($allPropertyNames, $this->request->getArguments(), $this->arguments, $optionalPropertyNames, $validator);
+
                $this->argumentsMappingResults = $this->propertyMapper->getMappingResults();
        }
 }
index 81f1113..3796dca 100644 (file)
@@ -124,7 +124,6 @@ class Tx_Extbase_MVC_Controller_ActionController extends Tx_Extbase_MVC_Controll
                $this->actionMethodName = $this->resolveActionMethodName();
 
                $this->initializeActionMethodArguments();
-               $this->initializeControllerArgumentsBaseValidators();
                $this->initializeActionMethodValidators();
 
                $this->initializeAction();
@@ -150,14 +149,16 @@ class Tx_Extbase_MVC_Controller_ActionController extends Tx_Extbase_MVC_Controll
         */
        protected function initializeActionMethodArguments() {
                $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), $this->actionMethodName);
+
                foreach ($methodParameters as $parameterName => $parameterInfo) {
-                       $dataType = 'Text';
+                       $dataType = NULL;
                        if (isset($parameterInfo['type'])) {
                                $dataType = $parameterInfo['type'];
                        } elseif ($parameterInfo['array']) {
                                $dataType = 'array';
                        }
-                       // TODO Exception here if type has not been determined!
+                       if ($dataType === NULL) throw new Tx_Extbase_MVC_Exception_InvalidArgumentType('The argument type for parameter "' . $parameterName . '" could not be detected.', 1253175643);
+
                        $defaultValue = (isset($parameterInfo['defaultValue']) ? $parameterInfo['defaultValue'] : NULL);
 
                        $this->arguments->addNewArgument($parameterName, $dataType, ($parameterInfo['optional'] === FALSE), $defaultValue);
@@ -165,40 +166,36 @@ class Tx_Extbase_MVC_Controller_ActionController extends Tx_Extbase_MVC_Controll
        }
 
        /**
-        * Detects and registers any additional validators for arguments which were
-        * specified in the @validate annotations of an action method
+        * Adds the needed valiators to the Arguments:
+        * - Validators checking the data type from the @param annotation
+        * - Custom validators specified with @validate.
+        *
+        * In case @dontvalidate is NOT set for an argument, the following two
+        * validators are also added:
+        * - Model-based validators (@validate annotations in the model)
+        * - Custom model validator classes
         *
         * @return void
         */
        protected function initializeActionMethodValidators() {
-               $validatorConjunctions = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($this), $this->actionMethodName);
-               foreach ($validatorConjunctions as $argumentName => $validatorConjunction) {
-                       if (!isset($this->arguments[$argumentName])) throw new Tx_Extbase_MVC_Exception_NoSuchArgument('Found custom validation rule for non existing argument "' . $argumentName . '" in ' . get_class($this) . '->' . $this->actionMethodName . '().', 1239853108);
-                       $argument = $this->arguments[$argumentName];
-                       $existingValidator = $argument->getValidator();
-                       if ($existingValidator !== NULL) {
-                               $validatorConjunction->addValidator($existingValidator);
-                       }
-                       $argument->setValidator($validatorConjunction);
-               }
-
-               $this->evaluateDontValidateAnnotations();
-       }
+               $parameterValidators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($this), $this->actionMethodName);
 
-       /**
-        * Parses @dontvalidate annotations of an action method an disables validation for
-        * the specified arguments.
-        *
-        * @return void
-        */
-       protected function evaluateDontValidateAnnotations() {
+               $dontValidateAnnotations = array();
                $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
                if (isset($methodTagsValues['dontvalidate'])) {
-                       foreach ($methodTagsValues['dontvalidate'] as $dontValidateValue) {
-                               $argumentName = substr($dontValidateValue, 1);
-                               if (!isset($this->arguments[$argumentName])) throw new Tx_Extbase_MVC_Exception_NoSuchArgument('Found @dontvalidate annotation for non existing argument "$' . $argumentName . '" in ' . get_class($this) . '->' . $this->actionMethodName . '().', 1249484908);
-                               $this->arguments[$argumentName]->disableValidation();
+                       $dontValidateAnnotations = $methodTagsValues['dontvalidate'];
+               }
+
+               foreach ($this->arguments as $argument) {
+                       $validator = $parameterValidators[$argument->getName()];
+
+                       if (array_search('$' . $argument->getName(), $dontValidateAnnotations) === FALSE) {
+                               $baseValidatorConjunction = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType());
+                               if ($baseValidatorConjunction !== NULL) {
+                                       $validator->addValidator($baseValidatorConjunction);
+                               }
                        }
+                       $argument->setValidator($validator);
                }
        }
 
@@ -348,6 +345,11 @@ class Tx_Extbase_MVC_Controller_ActionController extends Tx_Extbase_MVC_Controll
                $this->request->setErrors($this->argumentsMappingResults->getErrors());
                $this->clearCacheOnError();
 
+               $errorFlashMessage = $this->getErrorFlashMessage();
+               if ($errorFlashMessage !== FALSE) {
+                       $this->flashMessages->add($errorFlashMessage);
+               }
+               
                if ($this->request->hasArgument('__referrer')) {
                        $referrer = $this->request->getArgument('__referrer');
                        $this->forward($referrer['actionName'], $referrer['controllerName'], $referrer['extensionName'], $this->request->getArguments());
index 2149d58..8da877e 100644 (file)
@@ -98,12 +98,6 @@ class Tx_Extbase_MVC_Controller_Argument {
         */
        protected $validator = NULL;
 
-       /**
-        * If validation for this argument is temporarily disabled
-        * @var boolean
-        */
-       protected $validationDisabled = FALSE;
-
        /**
         * Uid for the argument, if it has one
         * @var string
@@ -287,40 +281,6 @@ class Tx_Extbase_MVC_Controller_Argument {
                return $this->validator;
        }
 
-       /**
-        * Returns TRUE if validation is temporarily disabled for this argument and
-        * FALSE if it's enabled.
-        *
-        * Note that this is flag is only informational and does not have any real impact
-        * on other validation methods of this argument.
-        *
-        * @return boolean If validation is disabled
-        * @api
-        */
-       public function isValidationDisabled() {
-               return $this->validationDisabled;
-       }
-
-       /**
-        * Enables validation for this argument.
-        *
-        * @return void
-        * @api
-        */
-       public function enableValidation() {
-               $this->validationDisabled = FALSE;
-       }
-
-       /**
-        * Disables validation for this argument.
-        *
-        * @return void
-        * @api
-        */
-       public function disableValidation() {
-               $this->validationDisabled = TRUE;
-       }
-
        /**
         * Sets the value of this argument.
         *
index b5e0929..847c7a9 100644 (file)
@@ -50,9 +50,6 @@ class Tx_Extbase_MVC_Controller_ArgumentsValidator extends Tx_Extbase_Validation
 
                $result = TRUE;
                foreach ($arguments->getArgumentNames() as $argumentName) {
-                       if ($arguments[$argumentName]->isValidationDisabled()) {
-                               continue;
-                       }
                        if ($this->isPropertyValid($arguments, $argumentName) === FALSE) {
                                $result = FALSE;
                        }
diff --git a/typo3/sysext/extbase/Classes/Validation/Exception/InvalidValidationConfiguration.php b/typo3/sysext/extbase/Classes/Validation/Exception/InvalidValidationConfiguration.php
new file mode 100644 (file)
index 0000000..b65d558
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This class is a backport of the corresponding class of FLOW3.
+*  All credits go to the v5 team.
+*
+*  This script is part of the TYPO3 project. The TYPO3 project 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 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * A "InvalidValidationConfiguration" Exception
+ *
+ * @package Extbase
+ * @subpackage Validation\Exception
+ * @version $ID:$
+ */
+class Tx_Extbase_Validation_Exception_InvalidValidationConfiguration extends Tx_Extbase_Validation_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php
new file mode 100644 (file)
index 0000000..867bc04
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This class is a backport of the corresponding class of FLOW3. 
+*  All credits go to the v5 team.
+*
+*  This script is part of the TYPO3 project. The TYPO3 project 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 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Validator for string length
+ *
+ * @package Extbase
+ * @subpackage Validation\Validator
+ * @version $Id: StringLengthValidator.php 1052 2009-08-05 21:51:32Z sebastian $
+ * @scope prototype
+ */
+class Tx_Extbase_Validation_Validator_StringValidator extends Tx_Extbase_Validation_Validator_AbstractValidator {
+
+       /**
+        * Returns TRUE, if the given property ($value) is a valid string.
+        *
+        * Otherwise, it is FALSE.
+        *
+        * @param mixed $value The value that should be validated
+        * @return boolean TRUE if the value is valid, FALSE if an error occured
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        * @api
+        */
+       public function isValid($value) {
+               return is_string($value);
+       }
+}
+
+?>
\ No newline at end of file
index 13de924..fb582ef 100644 (file)
  */
 class Tx_Extbase_Validation_ValidatorResolver {
 
+       /**
+        * Match validator names and options
+        * @var string
+        */
+       const PATTERN_MATCH_VALIDATORS = '/(?:^|,\s*)(?P<validatorName>[a-z0-9_]+)\s*(?:\((?P<validatorOptions>.+)\))?/i';
+
        /**
         * @var Tx_Extbase_Object_ManagerInterface
         */
@@ -82,8 +88,12 @@ class Tx_Extbase_Validation_ValidatorResolver {
                $validatorClassName = $this->resolveValidatorObjectName($validatorName);
                if ($validatorClassName === FALSE) return NULL;
                $validator = $this->objectManager->getObject($validatorClassName);
+               if (!($validator instanceof Tx_Extbase_Validation_Validator_ValidatorInterface)) {
+                       return NULL;
+               }
+
                $validator->setOptions($validatorOptions);
-               return ($validator instanceof Tx_Extbase_Validation_Validator_ValidatorInterface) ? $validator : NULL;
+               return $validator;
        }
 
        /**
@@ -103,40 +113,39 @@ class Tx_Extbase_Validation_ValidatorResolver {
        }
 
        /**
-        * Detects and registers any additional validators for arguments which were specified in the @validate
-        * annotations of a method.
+        * Detects and registers any validators for arguments:
+        * - by the data type specified in the @param annotations
+        * - additional validators specified in the @validate annotations of a method
         *
-        * @return array Validator Conjunctions
+        * @return array An Array of ValidatorConjunctions for each method parameters.
         */
        public function buildMethodArgumentsValidatorConjunctions($className, $methodName) {
                $validatorConjunctions = array();
 
+               $methodParameters = $this->reflectionService->getMethodParameters($className, $methodName);
                $methodTagsValues = $this->reflectionService->getMethodTagsValues($className, $methodName);
+               if (!count($methodParameters)) {
+                       // early return in case no parameters were found.
+                       return $validatorConjunctions;
+               }
+               foreach ($methodParameters as $parameterName => $methodParameter) {
+                       $validatorConjunction = $this->createValidator('Conjunction');
+                       $typeValidator = $this->createValidator($methodParameter['type']);
+                       if ($typeValidator !== NULL) $validatorConjunction->addValidator($typeValidator);
+                       $validatorConjunctions[$parameterName] = $validatorConjunction;
+               }
+
                if (isset($methodTagsValues['validate'])) {
                        foreach ($methodTagsValues['validate'] as $validateValue) {
-                               $matches = array();
-                               preg_match('/^\$(?P<argumentName>[a-zA-Z0-9]+)\s+(?P<validators>.*)$/', $validateValue, $matches);
-                               $argumentName = $matches['argumentName'];
-
-                               preg_match_all('/(?P<validatorName>[a-zA-Z0-9]+)(?:\((?P<validatorOptions>[^)]+)\))?/', $matches['validators'], $matches, PREG_SET_ORDER);
-                               foreach ($matches as $match) {
-                                       $validatorName = $match['validatorName'];
-                                       $validatorOptions = array();
-                                       $rawValidatorOptions = isset($match['validatorOptions']) ? explode(',', $match['validatorOptions']) : array();
-                                       foreach ($rawValidatorOptions as $rawValidatorOption) {
-                                               if (strpos($rawValidatorOption, '=') !== FALSE) {
-                                                       list($optionName, $optionValue) = explode('=', $rawValidatorOption);
-                                                       $validatorOptions[trim($optionName)] = trim($optionValue);
-                                               }
-                                       }
-                                       $newValidator = $this->createValidator($validatorName, $validatorOptions);
-                                       if ($newValidator === NULL) throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Could not resolve class name for  validator "' . $validatorName . '".', 1239853109);
+                               $parsedAnnotation = $this->parseValidatorAnnotation($validateValue);
+                               foreach ($parsedAnnotation['validators'] as $validatorConfiguration) {
+                                       $newValidator = $this->createValidator($validatorConfiguration['validatorName'], $validatorConfiguration['validatorOptions']);
+                                       if ($newValidator === NULL) throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Could not resolve class name for  validator "' . $validatorConfiguration['validatorName'] . '".', 1239853109);
 
-                                       if  (isset($validatorConjunctions[$argumentName])) {
-                                               $validatorConjunctions[$argumentName]->addValidator($newValidator);
+                                       if  (isset($validatorConjunctions[$parsedAnnotation['argumentName']])) {
+                                               $validatorConjunctions[$parsedAnnotation['argumentName']]->addValidator($newValidator);
                                        } else {
-                                               $validatorConjunctions[$argumentName] = $this->createValidator('Conjunction');
-                                               $validatorConjunctions[$argumentName]->addValidator($newValidator);
+                                               throw new Tx_Extbase_Validation_Exception_InvalidValidationConfiguration('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Validator specified for argument name "' . $parsedAnnotation['argumentName'] . '", but this argument does not exist.', 1253172726);
                                        }
                                }
                        }
@@ -148,18 +157,22 @@ class Tx_Extbase_Validation_ValidatorResolver {
         * Builds a base validator conjunction for the given data type.
         *
         * The base validation rules are those which were declared directly in a class (typically
-        * a model) through some @validate annotations.
+        * a model) through some @validate annotations on properties.
         *
         * Additionally, if a custom validator was defined for the class in question, it will be added
         * to the end of the conjunction. A custom validator is found if it follows the naming convention
-        * "[FullyqualifiedModelClassName]Validator".
+        * "Replace '\Model\' by '\Validator\' and append "Validator".
+        *
+        * Example: $dataType is F3\Foo\Domain\Model\Quux, then the Validator will be found if it has the
+        * name F3\Foo\Domain\Validator\QuuxValidator
         *
-        * @param string $dataType The data type to build the validation conjunction for. Usually the fully qualified object name.
+        * @param string $dataType The data type to build the validation conjunction for. Needs to be the fully qualified object name.
         * @return Tx_Extbase_Validation_Validator_ConjunctionValidator The validator conjunction or NULL
         */
        protected function buildBaseValidatorConjunction($dataType) {
                $validatorConjunction = $this->objectManager->getObject('Tx_Extbase_Validation_Validator_ConjunctionValidator');
 
+               // Model based validator
                if (class_exists($dataType)) {
                        $validatorCount = 0;
                        $objectValidator = $this->createValidator('GenericObject');
@@ -169,20 +182,12 @@ class Tx_Extbase_Validation_ValidatorResolver {
                                if (!isset($classPropertyTagsValues['validate'])) continue;
 
                                foreach ($classPropertyTagsValues['validate'] as $validateValue) {
-                                       $matches = array();
-                                       preg_match_all('/(?P<validatorName>[a-zA-Z0-9]+)(?:\((?P<validatorOptions>[^)]+)\))?/', $validateValue, $matches, PREG_SET_ORDER);
-                                       foreach ($matches as $match) {
-                                               $validatorName = $match['validatorName'];
-                                               $validatorOptions = array();
-                                               $rawValidatorOptions = isset($match['validatorOptions']) ? explode(',', $match['validatorOptions']) : array();
-                                               foreach ($rawValidatorOptions as $rawValidatorOption) {
-                                                       if (strpos($rawValidatorOption, '=') !== FALSE) {
-                                                               list($optionName, $optionValue) = explode('=', $rawValidatorOption);
-                                                               $validatorOptions[trim($optionName)] = trim($optionValue);
-                                                       }
+                                       $parsedAnnotation = $this->parseValidatorAnnotation($validateValue);
+                                       foreach ($parsedAnnotation['validators'] as $validatorConfiguration) {
+                                               $newValidator = $this->createValidator($validatorConfiguration['validatorName'], $validatorConfiguration['validatorOptions']);
+                                               if ($newValidator === NULL) {
+                                                       throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Invalid validate annotation in ' . $dataType . '::' . $classPropertyName . ': Could not resolve class name for  validator "' . $validatorConfiguration['validatorName'] . '".', 1241098027);
                                                }
-                                               $newValidator = $this->createValidator($validatorName, $validatorOptions);
-                                               if ($newValidator === NULL) throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Invalid validate annotation in ' . $dataType . '::' . $classPropertyName . ': Could not resolve class name for  validator "' . $validatorName . '".', 1241098027);
                                                $objectValidator->addPropertyValidator($classPropertyName, $newValidator);
                                                $validatorCount ++;
                                        }
@@ -191,16 +196,99 @@ class Tx_Extbase_Validation_ValidatorResolver {
                        if ($validatorCount > 0) $validatorConjunction->addValidator($objectValidator);
                }
 
+               // Custom validator for the class
                $possibleValidatorClassName = str_replace('_Model_', '_Validator_', $dataType) . 'Validator';
-               $customValidatorObjectName = $this->resolveValidatorObjectName($possibleValidatorClassName);
-               if ($customValidatorObjectName !== FALSE) {
-                       $validatorConjunction->addValidator($this->objectManager->getObject($customValidatorObjectName));
+               $customValidator = $this->createValidator($possibleValidatorClassName);
+               if ($customValidator !== NULL) {
+                       $validatorConjunction->addValidator($customValidator);
                }
 
                return $validatorConjunction;
        }
 
        /**
+        * Parses the validator options given in @validate annotations.
+        *
+        * @return array
+        */
+       protected function parseValidatorAnnotation($validateValue) {
+               $matches = array();
+               if ($validateValue[0] === '$') {
+                       $parts = explode(' ', $validateValue, 2);
+                       $validatorConfiguration = array('argumentName' => ltrim($parts[0], '$'), 'validators' => array());
+                       preg_match_all(self::PATTERN_MATCH_VALIDATORS, $parts[1], $matches, PREG_SET_ORDER);
+               } else {
+                       preg_match_all(self::PATTERN_MATCH_VALIDATORS, $validateValue, $matches, PREG_SET_ORDER);
+               }
+
+               foreach ($matches as $match) {
+                       $validatorName = $match['validatorName'];
+                       $validatorOptions = array();
+                       if (isset($match['validatorOptions'])) {
+                               if (strpos($match['validatorOptions'], '\'') === FALSE && strpos($match['validatorOptions'], '"') === FALSE) {
+                                       $validatorOptions = $this->parseSimpleValidatorOptions($match['validatorOptions']);
+                               } else {
+                                       $validatorOptions = $this->parseComplexValidatorOptions($match['validatorOptions']);
+                               }
+                       }
+                       $validatorConfiguration['validators'][] = array('validatorName' => $validatorName, 'validatorOptions' => $validatorOptions);
+               }
+
+               return $validatorConfiguration;
+       }
+
+       /**
+        * Parses $rawValidatorOptions not containing quoted option values.
+        * $rawValidatorOptions will be an empty string afterwards (pass by ref!).
+        *
+        * @param string &$rawValidatorOptions
+        * @return array An array of optionName/optionValue pairs
+        */
+       protected function parseSimpleValidatorOptions(&$rawValidatorOptions) {
+               $validatorOptions = array();
+
+               $rawValidatorOptions = explode(',', $rawValidatorOptions);
+               foreach ($rawValidatorOptions as $rawValidatorOption) {
+                       if (strpos($rawValidatorOption, '=') !== FALSE) {
+                               list($optionName, $optionValue) = explode('=', $rawValidatorOption, 2);
+                               $validatorOptions[trim($optionName)] = trim($optionValue);
+                       }
+               }
+
+               $rawValidatorOptions = '';
+               return $validatorOptions;
+       }
+
+       /**
+        * Parses $rawValidatorOptions containing quoted option values.
+        *
+        * @param string $rawValidatorOptions
+        * @return array An array of optionName/optionValue pairs
+        */
+       protected function parseComplexValidatorOptions($rawValidatorOptions) {
+               $validatorOptions = array();
+
+               while (strlen($rawValidatorOptions) > 0) {
+                       $parts = explode('=', $rawValidatorOptions, 2);
+                       $optionName = trim($parts[0]);
+                       $rawValidatorOptions = trim($parts[1]);
+
+                       $matches = array();
+                       preg_match('/(?:\'(.+)\'|"(.+)")(?:,|$)/', $rawValidatorOptions, $matches);
+                       $validatorOptions[$optionName] = str_replace(array('\\\'', '\\"'), array('\'', '"'), (isset($matches[2]) ? $matches[2] : $matches[1]));
+
+                       $rawValidatorOptions = ltrim(substr($rawValidatorOptions, strlen($matches[0])),', ');
+                       if (strpos($rawValidatorOptions, '\'') === FALSE && strpos($rawValidatorOptions, '"') === FALSE) {
+                               $validatorOptions = array_merge($validatorOptions, $this->parseSimpleValidatorOptions($rawValidatorOptions));
+                       }
+               }
+
+               return $validatorOptions;
+       }
+
+       /**
+        *
+        *
         * Returns an object of an appropriate validator for the given class. If no validator is available
         * NULL is returned
         *
@@ -208,8 +296,7 @@ class Tx_Extbase_Validation_ValidatorResolver {
         * @return string Name of the validator object or FALSE
         */
        protected function resolveValidatorObjectName($validatorName) {
-               // @TODO: Quick and dirty:
-               if (class_exists($validatorName) && substr($validatorName, -9) === 'Validator') return $validatorName;
+               if (class_exists($validatorName)) return $validatorName;
 
                $possibleClassName = 'Tx_Extbase_Validation_Validator_' . $this->unifyDataType($validatorName) . 'Validator';
                if (class_exists($possibleClassName)) return $possibleClassName;
@@ -228,9 +315,6 @@ class Tx_Extbase_Validation_ValidatorResolver {
                        case 'int' :
                                $type = 'Integer';
                                break;
-                       case 'string' :
-                               $type = 'Text';
-                               break;
                        case 'bool' :
                                $type = 'Boolean';
                                break;
index 24013ba..58da52e 100644 (file)
@@ -29,28 +29,29 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function processRequestSticksToSpecifiedSequence() {
-                // TODO mock uriBuilder after object factory was implemented
                $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
                $mockRequest->expects($this->once())->method('setDispatched')->with(TRUE);
 
-               $mockResponse = $this->getMock('Tx_Extbase_MVC_Response', array(), array(), '', FALSE);
+               $mockResponse = $this->getMock('Tx_Extbase_MVC_Web_Response', array(), array(), '', FALSE);
 
                $mockView = $this->getMock('Tx_Extbase_MVC_View_ViewInterface');
 
                $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array(
-                       'initializeFooAction', 'initializeAction', 'resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'mapRequestArgumentsToControllerArguments', 'initializeControllerArgumentsBaseValidators', 'resolveView', 'initializeView', 'callActionMethod'));
+                       'initializeFooAction', 'initializeAction', 'resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'mapRequestArgumentsToControllerArguments', 'resolveView', 'initializeView', 'callActionMethod'),
+                       array(), '', FALSE);
+               $mockController->_set('objectFactory', $mockObjectFactory);
                $mockController->expects($this->at(0))->method('resolveActionMethodName')->will($this->returnValue('fooAction'));
                $mockController->expects($this->at(1))->method('initializeActionMethodArguments');
                $mockController->expects($this->at(2))->method('initializeActionMethodValidators');
                $mockController->expects($this->at(3))->method('initializeAction');
                $mockController->expects($this->at(4))->method('initializeFooAction');
-               $mockController->expects($this->at(5))->method('initializeControllerArgumentsBaseValidators');
-               $mockController->expects($this->at(6))->method('mapRequestArgumentsToControllerArguments');
-               $mockController->expects($this->at(7))->method('resolveView')->will($this->returnValue($mockView));
-               $mockController->expects($this->at(8))->method('initializeView');
-               $mockController->expects($this->at(9))->method('callActionMethod');
+               $mockController->expects($this->at(5))->method('mapRequestArgumentsToControllerArguments');
+               $mockController->expects($this->at(6))->method('resolveView')->will($this->returnValue($mockView));
+               $mockController->expects($this->at(7))->method('initializeView');
+               $mockController->expects($this->at(8))->method('callActionMethod');
 
                $mockController->processRequest($mockRequest, $mockResponse);
                $this->assertSame($mockRequest, $mockController->_get('request'));
@@ -59,15 +60,15 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function callActionMethodAppendsStringsReturnedByActionMethodToTheResponseObject() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
-               $mockResponse = $this->getMock('Tx_Extbase_MVC_Response', array(), array(), '', FALSE);
+               $mockResponse = $this->getMock('Tx_Extbase_MVC_ResponseInterface', array(), array(), '', FALSE);
                $mockResponse->expects($this->once())->method('appendContent')->with('the returned string');
 
-               $mockArguments = $this->getMock('Tx_Extbase_Controller_Arguments', array('areValid'), array(), '', FALSE);
-               $mockArguments->expects($this->any())->method('areValid')->will($this->returnValue(TRUE));
+               $mockArguments = new ArrayObject;
 
                $mockArgumentMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
@@ -84,18 +85,18 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function callActionMethodRendersTheViewAutomaticallyIfTheActionReturnedNullAndAViewExists() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
-               $mockResponse = $this->getMock('Tx_Extbase_MVC_Response', array(), array(), '', FALSE);
+               $mockResponse = $this->getMock('Tx_Extbase_MVC_ResponseInterface', array(), array(), '', FALSE);
                $mockResponse->expects($this->once())->method('appendContent')->with('the view output');
 
                $mockView = $this->getMock('Tx_Extbase_MVC_View_ViewInterface');
                $mockView->expects($this->once())->method('render')->will($this->returnValue('the view output'));
 
-               $mockArguments = $this->getMock('Tx_Extbase_Controller_Arguments', array('areValid'), array(), '', FALSE);
-               $mockArguments->expects($this->any())->method('areValid')->will($this->returnValue(TRUE));
+               $mockArguments = new ArrayObject;
 
                $mockArgumentMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
@@ -113,21 +114,21 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function callActionMethodCallsTheErrorActionIfTheMappingResultsHaveErrors() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
-               $mockResponse = $this->getMock('Tx_Extbase_MVC_Response', array(), array(), '', FALSE);
+               $mockResponse = $this->getMock('Tx_Extbase_MVC_ResponseInterface', array(), array(), '', FALSE);
                $mockResponse->expects($this->once())->method('appendContent')->with('the returned string');
 
-               $mockArguments = $this->getMock('Tx_Extbase_Controller_Arguments', array('areValid'), array(), '', FALSE);
-               $mockArguments->expects($this->any())->method('areValid')->will($this->returnValue(TRUE));
+               $mockArguments = new ArrayObject;
 
                $mockArgumentMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array(), array(), '', FALSE);
-               $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
+               $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(TRUE));
 
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction', 'initializeAction'), array(), '', FALSE);
-               $mockController->expects($this->once())->method('fooAction')->will($this->returnValue('the returned string'));
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('barAction', 'initializeAction'), array(), '', FALSE);
+               $mockController->expects($this->once())->method('barAction')->will($this->returnValue('the returned string'));
                $mockController->_set('request', $mockRequest);
                $mockController->_set('response', $mockResponse);
                $mockController->_set('arguments', $mockArguments);
@@ -139,17 +140,17 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function callActionMethodPassesDefaultValuesAsArguments() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
-               $mockResponse = $this->getMock('Tx_Extbase_MVC_Response', array(), array(), '', FALSE);
+               $mockResponse = $this->getMock('Tx_Extbase_MVC_ResponseInterface', array(), array(), '', FALSE);
 
-               $mockArguments = $this->getMock('ArrayObject', array('areValid'), array(), '', FALSE);
-               $mockArguments->expects($this->any())->method('areValid')->will($this->returnValue(TRUE));
+               $arguments = new ArrayObject();
                $optionalArgument = new Tx_Extbase_MVC_Controller_Argument('name1', 'Text');
                $optionalArgument->setDefaultValue('Default value');
-               $mockArguments[] = $optionalArgument;
+               $arguments[] = $optionalArgument;
 
                $mockArgumentMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array(), array(), '', FALSE);
                $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE));
@@ -158,7 +159,7 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
                $mockController->expects($this->once())->method('fooAction')->with('Default value');
                $mockController->_set('request', $mockRequest);
                $mockController->_set('response', $mockResponse);
-               $mockController->_set('arguments', $mockArguments);
+               $mockController->_set('arguments', $arguments);
                $mockController->_set('actionMethodName', 'fooAction');
                $mockController->_set('argumentsMappingResults', $mockArgumentMappingResults);
                $mockController->_call('callActionMethod');
@@ -166,19 +167,22 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function resolveViewUsesFluidTemplateViewIfTemplateIsAvailable() {
+               $mockSession = $this->getMock('Tx_Extbase_Session_SessionInterface');
                $mockControllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
 
-               $mockFluidTemplateView = $this->getMock('Tx_Fluid_View_TemplateView', array('setControllerContext', 'getViewHelper', 'assign', 'render', 'hasTemplate'));
+               $mockFluidTemplateView = $this->getMock('Tx_Extbase_MVC_View_ViewInterface', array('setControllerContext', 'getViewHelper', 'assign', 'assignMultiple', 'render', 'hasTemplate', 'initializeView'));
                $mockFluidTemplateView->expects($this->once())->method('setControllerContext')->with($mockControllerContext);
                $mockFluidTemplateView->expects($this->once())->method('hasTemplate')->will($this->returnValue(TRUE));
 
                $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface', array(), array(), '', FALSE);
                $mockObjectManager->expects($this->at(0))->method('getObject')->with('Tx_Fluid_View_TemplateView')->will($this->returnValue($mockFluidTemplateView));
 
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('buildControllerContext', 'resolveViewObjectName', 'popFlashMessages'), array(), '', FALSE);
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('buildControllerContext'), array(), '', FALSE);
                $mockController->expects($this->once())->method('buildControllerContext')->will($this->returnValue($mockControllerContext));
+               $mockController->_set('session', $mockSession);
                $mockController->_set('objectManager', $mockObjectManager);
 
                $this->assertSame($mockFluidTemplateView, $mockController->_call('resolveView'));
@@ -186,83 +190,38 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
-        */
-       public function resolveViewPreparesTheViewSpecifiedInTheRequestObjectAndUsesTheEmptyViewIfNoneCouldBeFound() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
-               $mockRequest->expects($this->at(0))->method('getControllerExtensionName')->will($this->returnValue('Foo'));
-               $mockRequest->expects($this->at(1))->method('getControllerName')->will($this->returnValue('Test'));
-               $mockRequest->expects($this->at(2))->method('getControllerActionName')->will($this->returnValue('list'));
-               $mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('html'));
-
-               $mockControllerContext = $this->getMock('Tx_extbase_MVC_Controller_ControllerContext', array('getRequest'), array(), '', FALSE);
-               $mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
-
-               $mockFluidTemplateView = $this->getMock('Tx_Extbase_MVC_View_ViewInterface', array('setControllerContext', 'getViewHelper', 'assign', 'assignMultiple', 'render', 'hasTemplate', 'initializeView'));
-               $mockFluidTemplateView->expects($this->once())->method('setControllerContext')->with($mockControllerContext);
-               $mockFluidTemplateView->expects($this->once())->method('hasTemplate')->will($this->returnValue(FALSE));
-
-               $mockView = $this->getMock('Tx_Extbase_MVC_View_ViewInterface', array('setControllerContext', 'getViewHelper', 'assign', 'assignMultiple', 'render', 'hasTemplate', 'initializeView'));
-               $mockView->expects($this->once())->method('setControllerContext')->with($mockControllerContext);
-               $mockView->expects($this->once())->method('initializeView');
-
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
-               $mockObjectManager->expects($this->at(0))->method('getObject')->with('Tx_Fluid_View_TemplateView')->will($this->returnValue($mockFluidTemplateView));
-               $mockObjectManager->expects($this->at(1))->method('getObject')->with('Tx_Extbase_MVC_View_EmptyView')->will($this->returnValue($mockView));
-
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('buildControllerContext', 'popFlashMessages'), array(), '', FALSE);
-               $mockController->expects($this->once())->method('buildControllerContext')->will($this->returnValue($mockControllerContext));
-               $mockController->_set('request', $mockRequest);
-               $mockController->_set('objectManager', $mockObjectManager);
-
-               $this->assertSame($mockView, $mockController->_call('resolveView'));
-               }
-
-       /**
-        * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function resolveViewObjectNameUsesViewObjectNamePatternToResolveViewObjectName() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
-               $mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('MyExtension'));
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
+               $mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('MyPackage'));
                $mockRequest->expects($this->once())->method('getControllerName')->will($this->returnValue('MyController'));
-               $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('myAction'));
-
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('dummy'), array(), '', FALSE);
-               $mockController->_set('request', $mockRequest);
-               $mockController->_set('viewObjectNamePattern', 'RandomViewObjectPattern_@extension_View_@controller_@action');
-
-               eval('class RandomViewObjectPattern_MyExtension_View_MyController_MyAction {}');
-
-               $this->assertEquals('RandomViewObjectPattern_MyExtension_View_MyController_MyAction', $mockController->_call('resolveViewObjectName'));
-       }
-
-       /**
-        * @test
-        */
-       public function resolveViewObjectNameReturnsDefaultViewObjectNameIfNoCustomViewCanBeFound() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('MyAction'));
+               $mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('MyFormat'));
 
+               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface', array(), array(), '', FALSE);
+               
                $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('dummy'), array(), '', FALSE);
                $mockController->_set('request', $mockRequest);
-               $mockController->_set('defaultViewObjectName', 'MyDefaultViewObjectName');
-
-               eval('class MyDefaultViewObjectName {}');
+               $mockController->_set('objectManager', $mockObjectManager);
+               $mockController->_set('viewObjectNamePattern', 'RandomViewObjectPattern_@package_@controller_@action_@format');
 
-               $this->assertEquals('MyDefaultViewObjectName', $mockController->_call('resolveViewObjectName'));
+               $mockController->_call('resolveViewObjectName');
        }
 
-
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function initializeActionMethodArgumentsRegistersArgumentsFoundInTheSignatureOfTheCurrentActionMethod() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
-               $mockArguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array(), array(), '', FALSE);
+               $mockArguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array('addNewArgument', 'removeAll'), array(), '', FALSE);
                $mockArguments->expects($this->at(0))->method('addNewArgument')->with('stringArgument', 'string', TRUE);
                $mockArguments->expects($this->at(1))->method('addNewArgument')->with('integerArgument', 'integer', TRUE);
-               $mockArguments->expects($this->at(2))->method('addNewArgument')->with('objectArgument', 'Tx_Foo_Bar', TRUE);
+               $mockArguments->expects($this->at(2))->method('addNewArgument')->with('objectArgument', 'F3_Foo_Bar', TRUE);
 
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction', 'evaluateDontValidateAnnotations'), array(), '', FALSE);
 
                $methodParameters = array(
                        'stringArgument' => array(
@@ -287,7 +246,7 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
                                'array' => FALSE,
                                'optional' => FALSE,
                                'allowsNull' => FALSE,
-                               'type' => 'Tx_Foo_Bar'
+                               'type' => 'F3_Foo_Bar'
                        )
                );
 
@@ -303,16 +262,17 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
         */
        public function initializeActionMethodArgumentsRegistersOptionalArgumentsAsSuch() {
-               $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array(), array(), '', FALSE);
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
 
                $mockArguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array(), array(), '', FALSE);
-               $mockArguments->expects($this->at(0))->method('addNewArgument')->with('arg1', 'Text', TRUE);
+               $mockArguments->expects($this->at(0))->method('addNewArgument')->with('arg1', 'string', TRUE);
                $mockArguments->expects($this->at(1))->method('addNewArgument')->with('arg2', 'array', FALSE, array(21));
-               $mockArguments->expects($this->at(2))->method('addNewArgument')->with('arg3', 'Text', FALSE, 42);
+               $mockArguments->expects($this->at(2))->method('addNewArgument')->with('arg3', 'string', FALSE, 42);
 
-               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction', 'evaluateDontValidateAnnotations'), array(), '', FALSE);
 
                $methodParameters = array(
                        'arg1' => array(
@@ -320,7 +280,8 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
                                'byReference' => FALSE,
                                'array' => FALSE,
                                'optional' => FALSE,
-                               'allowsNull' => FALSE
+                               'allowsNull' => FALSE,
+                               'type' => 'string'
                        ),
                        'arg2' => array(
                                'position' => 1,
@@ -336,15 +297,40 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
                                'array' => FALSE,
                                'optional' => TRUE,
                                'defaultValue' => 42,
-                               'allowsNull' => FALSE
+                               'allowsNull' => FALSE,
+                               'type' => 'string'
                        )
                );
 
-               $methodTagsValues = array(
-                       'param' => array(
-                               'string $arg1',
-                               'array $arg2',
-                               'string $arg3'
+               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
+               $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
+
+               $mockController->injectReflectionService($mockReflectionService);
+               $mockController->_set('request', $mockRequest);
+               $mockController->_set('arguments', $mockArguments);
+               $mockController->_set('actionMethodName', 'fooAction');
+               $mockController->_call('initializeActionMethodArguments');
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        * @expectedException Tx_Extbase_MVC_Exception_InvalidArgumentType
+        */
+       public function initializeActionMethodArgumentsThrowsExceptionIfDataTypeWasNotSpecified() {
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
+
+               $mockArguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array(), array(), '', FALSE);
+
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
+
+               $methodParameters = array(
+                       'arg1' => array(
+                               'position' => 0,
+                               'byReference' => FALSE,
+                               'array' => FALSE,
+                               'optional' => FALSE,
+                               'allowsNull' => FALSE,
                        )
                );
 
@@ -360,39 +346,147 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
 
        /**
         * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
         */
-       public function initializeActionMethodValidatorsDetectsValidateAnnotationsAndRegistersNewValidatorsForEachArgument() {
+       public function initializeActionMethodValidatorsCorrectlyRegistersValidatorsBasedOnDataType() {
                $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
 
-               $conjunction1 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $conjunction2 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+               $argument = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('getName'), array(), '', FALSE);
+               $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
+
+               $arguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array('dummy'), array(), '', FALSE);
+               $arguments->addArgument($argument);
+
+               $methodTagsValues = array(
 
-               $validatorConjunctions = array(
-                       'arg1' => $conjunction1,
-                       'arg2' => $conjunction2
                );
 
+               $methodArgumentsValidatorConjunctions = array();
+               $methodArgumentsValidatorConjunctions['arg1'] = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+
+               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
+
                $mockValidatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array(), array(), '', FALSE);
-               $mockValidatorResolver->expects($this->once())->method('buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController), 'fooAction')->will($this->returnValue($validatorConjunctions));
+               $mockValidatorResolver->expects($this->once())->method('buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
 
-               $mockArgument = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('setValidator'), array(), '', FALSE);
-               $mockArgument->expects($this->at(0))->method('setValidator')->with($conjunction1);
-               $mockArgument->expects($this->at(1))->method('setValidator')->with($conjunction2);
+               $mockController->injectReflectionService($mockReflectionService);
+               $mockController->injectValidatorResolver($mockValidatorResolver);
+               $mockController->_set('arguments', $arguments);
+               $mockController->_set('actionMethodName', 'fooAction');
+               $mockController->_call('initializeActionMethodValidators');
 
-               $mockArguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array(), array(), '', FALSE);
-               $mockArguments->expects($this->at(0))->method('offsetExists')->with('arg1')->will($this->returnValue(TRUE));
-               $mockArguments->expects($this->at(1))->method('offsetGet')->with('arg1')->will($this->returnValue($mockArgument));
-               $mockArguments->expects($this->at(2))->method('offsetExists')->with('arg2')->will($this->returnValue(TRUE));
-               $mockArguments->expects($this->at(3))->method('offsetGet')->with('arg2')->will($this->returnValue($mockArgument));
+               $this->assertEquals($methodArgumentsValidatorConjunctions['arg1'], $arguments['arg1']->getValidator());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        */
+       public function initializeActionMethodValidatorsRegistersModelBasedValidators() {
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
+
+               $argument = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('getName', 'getDataType'), array(), '', FALSE);
+               $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
+               $argument->expects($this->any())->method('getDataType')->will($this->returnValue('F3_Foo_Quux'));
+
+               $arguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array('dummy'), array(), '', FALSE);
+               $arguments->addArgument($argument);
+
+               $methodTagsValues = array(
+
+               );
+
+               $quuxBaseValidatorConjunction = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+
+               $methodArgumentsValidatorConjunctions = array();
+               $methodArgumentsValidatorConjunctions['arg1'] = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+               $methodArgumentsValidatorConjunctions['arg1']->expects($this->once())->method('addValidator')->with($quuxBaseValidatorConjunction);
 
                $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
-               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue(array('tag' => 'lorem ipsum')));
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
 
-               $mockController->_set('validatorResolver', $mockValidatorResolver);
+               $mockValidatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array(), array(), '', FALSE);
+               $mockValidatorResolver->expects($this->once())->method('buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
+               $mockValidatorResolver->expects($this->once())->method('getBaseValidatorConjunction')->with('F3_Foo_Quux')->will($this->returnValue($quuxBaseValidatorConjunction));
+
+               $mockController->injectReflectionService($mockReflectionService);
+               $mockController->injectValidatorResolver($mockValidatorResolver);
+               $mockController->_set('arguments', $arguments);
                $mockController->_set('actionMethodName', 'fooAction');
-               $mockController->_set('arguments', $mockArguments);
-               $mockController->_set('reflectionService', $mockReflectionService);
                $mockController->_call('initializeActionMethodValidators');
+
+               $this->assertEquals($methodArgumentsValidatorConjunctions['arg1'], $arguments['arg1']->getValidator());
+       }
+
+       /**
+        * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        */
+       public function initializeActionMethodValidatorsDoesNotRegisterModelBasedValidatorsIfDontValidateAnnotationIsSet() {
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
+
+               $argument = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('getName', 'getDataType'), array(), '', FALSE);
+               $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
+               $argument->expects($this->any())->method('getDataType')->will($this->returnValue('F3_Foo_Quux'));
+
+               $arguments = $this->getMock('Tx_Extbase_MVC_Controller_Arguments', array('dummy'), array(), '', FALSE);
+               $arguments->addArgument($argument);
+
+               $methodTagsValues = array(
+                       'dontvalidate' => array(
+                               '$arg1'
+                       )
+               );
+
+               $methodArgumentsValidatorConjunctions = array();
+               $methodArgumentsValidatorConjunctions['arg1'] = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+
+               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
+
+               $mockValidatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array(), array(), '', FALSE);
+               $mockValidatorResolver->expects($this->once())->method('buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
+               $mockValidatorResolver->expects($this->any())->method('getBaseValidatorConjunction')->will($this->throwException(new Exception("This should not be called because the dontvalidate annotation is set.")));
+
+               $mockController->injectReflectionService($mockReflectionService);
+               $mockController->injectValidatorResolver($mockValidatorResolver);
+               $mockController->_set('arguments', $arguments);
+               $mockController->_set('actionMethodName', 'fooAction');
+               $mockController->_call('initializeActionMethodValidators');
+
+               $this->assertEquals($methodArgumentsValidatorConjunctions['arg1'], $arguments['arg1']->getValidator());
+       }
+
+       /**
+        * @test
+        * @author Christopher Hlubek <hlubek@networkteam.com>
+        */
+       public function defaultErrorActionSetsArgumentMappingResultsErrorsInRequest() {
+               $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE);
+               $mockFlashMessages = $this->getMock('Tx_Extbase_MVC_Controller_FlashMessages', array(), array(), '', FALSE);
+
+               $mockError = $this->getMock('Tx_Extbase_Error_Error', array('getMessage'), array(), '', FALSE);
+               $mockArgumentsMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array('getErrors', 'getWarnings'), array(), '', FALSE);
+               $mockArgumentsMappingResults->expects($this->atLeastOnce())->method('getErrors')->will($this->returnValue(array($mockError)));
+               $mockArgumentsMappingResults->expects($this->any())->method('getWarnings')->will($this->returnValue(array()));
+
+               $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('pushFlashMessage'), array(), '', FALSE);
+               $mockController->_set('request', $mockRequest);
+               $mockController->_set('flashMessages', $mockFlashMessages);
+               $mockController->_set('argumentsMappingResults', $mockArgumentsMappingResults);
+
+               $mockRequest->expects($this->once())->method('setErrors')->with(array($mockError));
+
+               $mockController->_call('errorAction');
+       }
+
+       /**
+        * @test
+        * @author Christopher Hlubek <hlubek@networkteam.com>
+        */
+       public function defaultErrorActionCallsGetErrorFlashMessageAndPutsFlashMessage() {
+               $this->markTestIncomplete('To be implemented');
        }
 
 }
index ee978ac..4d5559e 100644 (file)
@@ -113,10 +113,42 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
 
        /**
         * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
         */
-       public function buildMethodArgumentsValidatorConjunctionsDetectsValidateAnnotationsAndRegistersNewValidatorsForEachArgument() {
+       public function buildMethodArgumentsValidatorConjunctionsReturnsEmptyArrayIfMethodHasNoArguments() {
                $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction'), array(), '', FALSE);
 
+               $methodTagsValues = array();
+               $methodParameters = array();
+
+               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
+               $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
+
+               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
+               $validatorResolver->injectReflectionService($mockReflectionService);
+
+               $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
+               $this->assertSame(array(), $result);
+       }
+
+       /**
+        * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function buildMethodArgumentsValidatorConjunctionsBuildsAConjunctionFromValidateAnnotationsOfTheSpecifiedMethod() {
+               $mockObject = $this->getMock('stdClass', array('fooMethod'), array(), '', FALSE);
+
+               $methodParameters = array(
+                       'arg1' => array(
+                               'type' => 'string'
+                       ),
+                       'arg2' => array(
+                               'type' => 'array'
+                       )
+
+               );
                $methodTagsValues = array(
                        'param' => array(
                                'string $arg1',
@@ -124,23 +156,30 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
                        ),
                        'validate' => array(
                                '$arg1 Foo(bar = baz), Bar',
-                               '$arg2 Quux'
+                               '$arg2 F3_TestPackage_Quux'
                        )
                );
 
                $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
-               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
+               $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
 
+               $mockStringValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
+               $mockArrayValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
                $mockFooValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
                $mockBarValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
                $mockQuuxValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
 
                $conjunction1 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $conjunction1->expects($this->at(0))->method('addValidator')->with($mockFooValidator);
-               $conjunction1->expects($this->at(1))->method('addValidator')->with($mockBarValidator);
+               $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
+               $conjunction1->expects($this->at(1))->method('addValidator')->with($mockFooValidator);
+               $conjunction1->expects($this->at(2))->method('addValidator')->with($mockBarValidator);
 
                $conjunction2 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $conjunction2->expects($this->at(0))->method('addValidator')->with($mockQuuxValidator);
+               $conjunction2->expects($this->at(0))->method('addValidator')->with($mockArrayValidator);
+               $conjunction2->expects($this->at(1))->method('addValidator')->with($mockQuuxValidator);
+
+               $mockObjectFactory = $this->getMock('Tx_Extbase_Object_FactoryInterface');
 
                $mockArguments = new Tx_Extbase_MVC_Controller_Arguments();
                $mockArguments->addArgument(new Tx_Extbase_MVC_Controller_Argument('arg1'));
@@ -149,50 +188,65 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
                $mockArguments['arg2'] = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array(), array(), '', FALSE);
 
                $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
-               $validatorResolver->expects($this->at(0))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockFooValidator));
-               $validatorResolver->expects($this->at(1))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction1));
-               $validatorResolver->expects($this->at(2))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
-               $validatorResolver->expects($this->at(3))->method('createValidator')->with('Quux')->will($this->returnValue($mockQuuxValidator));
-               $validatorResolver->expects($this->at(4))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction2));
+               $validatorResolver->expects($this->at(0))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction1));
+               $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
+               $validatorResolver->expects($this->at(2))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction2));
+               $validatorResolver->expects($this->at(3))->method('createValidator')->with('array')->will($this->returnValue($mockArrayValidator));
+               $validatorResolver->expects($this->at(4))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockFooValidator));
+               $validatorResolver->expects($this->at(5))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
+               $validatorResolver->expects($this->at(6))->method('createValidator')->with('F3_TestPackage_Quux')->will($this->returnValue($mockQuuxValidator));
 
                $validatorResolver->injectReflectionService($mockReflectionService);
 
-               $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
-               $this->assertSame(array('arg1' => $conjunction1, 'arg2' => $conjunction2), $result);
+               $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
+               $this->assertEquals(array('arg1' => $conjunction1, 'arg2' => $conjunction2), $result);
        }
 
        /**
         * @test
+        * @author Sebastian Kurfürst <sbastian@typo3.org>
+        * @expectedException Tx_Extbase_Validation_Exception_InvalidValidationConfiguration
         */
-       public function buildBaseValidatorConjunctionAddsCustomValidatorToTheReturnedConjunction() {
-               // TODO implement Data Provider
-               $modelClassName = 'Tx_Fruux_Domain_Model_Blog';
-               $validatorClassName = 'Tx_Fruux_Domain_Validator_BlogValidator';
-               eval('class Tx_Fruux_Domain_Validator_BlogValidator implements Tx_Extbase_Validation_Validator_ValidatorInterface {
-                       public function isValid($value) {}
-                       public function setOptions(array $validationOptions) {}
-                       public function getErrors() {}
-                       }');
-
-               $mockValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface');
+       public function buildMethodArgumentsValidatorConjunctionsThrowsExceptionIfValidationAnnotationForNonExistingArgumentExists() {
+               $mockObject = $this->getMock('stdClass', array('fooMethod'), array(), '', FALSE);
 
-               $mockConjunctionValidator = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $mockConjunctionValidator->expects($this->once())->method('addValidator')->with($mockValidator);
+               $methodParameters = array(
+                       'arg1' => array(
+                               'type' => 'string'
+                       )
+               );
+               $methodTagsValues = array(
+                       'param' => array(
+                               'string $arg1',
+                       ),
+                       'validate' => array(
+                               '$arg2 F3_TestPackage_Quux'
+                       )
+               );
 
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface', array(), array(), '', FALSE);
-               $mockObjectManager->expects($this->at(0))->method('getObject')->with('Tx_Extbase_Validation_Validator_ConjunctionValidator')->will($this->returnValue($mockConjunctionValidator));
-               $mockObjectManager->expects($this->at(1))->method('getObject')->with($validatorClassName)->will($this->returnValue($mockValidator));
+               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
+               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
+               $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
 
-               $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('resolveValidatorObjectName'));
-               $validatorResolver->_set('objectManager', $mockObjectManager);
-               $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($validatorClassName)->will($this->returnValue($validatorClassName));
+               $mockStringValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
+               $mockQuuxValidator = $this->getMock('Tx_Extbase_Validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
+               $conjunction1 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
+               $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
 
-               $result = $validatorResolver->_call('buildBaseValidatorConjunction', $modelClassName);
-               $this->assertSame($mockConjunctionValidator, $result);
+               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
+               $validatorResolver->expects($this->at(0))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction1));
+               $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
+               $validatorResolver->expects($this->at(2))->method('createValidator')->with('F3_TestPackage_Quux')->will($this->returnValue($mockQuuxValidator));
+
+               $validatorResolver->injectReflectionService($mockReflectionService);
+
+               $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
        }
 
        /**
         * @test
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Christopher Hlubek <hlubek@networkteam.com>
         */
        public function buildBaseValidatorConjunctionAddsValidatorsDefinedByAnnotationsInTheClassToTheReturnedConjunction() {
                $mockObject = $this->getMock('stdClass');
@@ -209,7 +263,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
                        'bar' => array(
                                'var' => array('integer'),
                                'validate' => array(
-                                       'Quux'
+                                       'F3_TestPackage_Quux'
                                )
                        )
                );
@@ -227,88 +281,42 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
                $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface', array(), array(), '', FALSE);
                $mockObjectManager->expects($this->at(0))->method('getObject')->with('Tx_Extbase_Validation_Validator_ConjunctionValidator')->will($this->returnValue($mockConjunctionValidator));
 
-               $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('resolveValidatorObjectName', 'createValidator'));
-               $validatorResolver->_set('objectManager', $mockObjectManager);
+               $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('resolveValidatorObjectName', 'createValidator'), array($mockObjectManager));
                $validatorResolver->injectReflectionService($mockReflectionService);
+               $validatorResolver->injectObjectManager($mockObjectManager);
 
-               $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($className . 'Validator')->will($this->returnValue(FALSE));
                $validatorResolver->expects($this->at(0))->method('createValidator')->with('GenericObject')->will($this->returnValue($mockObjectValidator));
                $validatorResolver->expects($this->at(1))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockObjectValidator));
                $validatorResolver->expects($this->at(2))->method('createValidator')->with('Bar')->will($this->returnValue($mockObjectValidator));
                $validatorResolver->expects($this->at(3))->method('createValidator')->with('Baz')->will($this->returnValue($mockObjectValidator));
-               $validatorResolver->expects($this->at(4))->method('createValidator')->with('Quux')->will($this->returnValue($mockObjectValidator));
+               $validatorResolver->expects($this->at(4))->method('createValidator')->with('F3_TestPackage_Quux')->will($this->returnValue($mockObjectValidator));
+               $validatorResolver->expects($this->at(5))->method('createValidator')->with($className . 'Validator')->will($this->returnValue(NULL));
 
                $result = $validatorResolver->_call('buildBaseValidatorConjunction', $className);
                $this->assertSame($mockConjunctionValidator, $result);
        }
 
-       /**
-        * test
-        */
-       public function buildMethodArgumentsValidatorConjunctionsBuildsAConjunctionFromValidateAnnotationsOfTheSpecifiedMethod() {
-               $mockObject = $this->getMock('stdClass', array('fooMethod'), array(), '', FALSE);
-
-               $methodTagsValues = array(
-                       'param' => array(
-                               'string $arg1',
-                               'array $arg2',
-                       ),
-                       'validate' => array(
-                               '$arg1 Foo(bar = baz), Bar',
-                               '$arg2 Quux'
-                       )
-               );
-
-               $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array(), array(), '', FALSE);
-               $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
-
-               $mockFooValidator = $this->getMock('Tx_Extbase_validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
-               $mockBarValidator = $this->getMock('Tx_Extbase_validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
-               $mockQuuxValidator = $this->getMock('Tx_Extbase_validation_Validator_ValidatorInterface', array(), array(), '', FALSE);
-
-               $conjunction1 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $conjunction1->expects($this->at(0))->method('addValidator')->with($mockFooValidator);
-               $conjunction1->expects($this->at(1))->method('addValidator')->with($mockBarValidator);
-
-               $conjunction2 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
-               $conjunction2->expects($this->at(0))->method('addValidator')->with($mockQuuxValidator);
-
-               $mockArguments = new Tx_Extbase_MVC_Controller_Arguments();
-               $mockArguments->addArgument(new Tx_Extbase_MVC_Controller_Argument('arg1'));
-               $mockArguments->addArgument(new Tx_Extbase_MVC_Controller_Argument('arg2'));
-
-               $mockArguments['arg2'] = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array(), array(), '', FALSE);
-
-               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
-               $validatorResolver->expects($this->at(0))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockFooValidator));
-               $validatorResolver->expects($this->at(1))->method('createValidator')->with('Chain')->will($this->returnValue($conjunction1));
-               $validatorResolver->expects($this->at(2))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
-               $validatorResolver->expects($this->at(3))->method('createValidator')->with('Quux')->will($this->returnValue($mockQuuxValidator));
-               $validatorResolver->expects($this->at(4))->method('createValidator')->with('Chain')->will($this->returnValue($conjunction2));
-
-               $validatorResolver->injectReflectionService($mockReflectionService);
-
-               $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
-               $this->assertSame(array('arg1' => $conjunction1, 'arg2' => $conjunction2), $result);
-       }
-
        /**
         * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function resolveValidatorObjectNameCallsUnifyDataType() {
-               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('unifyDataType'), array(), '', FALSE);
+               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
+               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('unifyDataType'), array($mockObjectManager));
                $mockValidator->expects($this->once())->method('unifyDataType')->with('someDataType');
                $mockValidator->_call('resolveValidatorObjectName', 'someDataType');
        }
 
        /**
         * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function unifyDataTypeCorrectlyRenamesPhpDataTypes() {
-               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'), array(), '', FALSE);
+       public function unifyDataTypeCorrectlyRenamesPHPDataTypes() {
+               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
+               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'), array($mockObjectManager), '', FALSE);
                $this->assertEquals('Integer', $mockValidator->_call('unifyDataType', 'integer'));
                $this->assertEquals('Integer', $mockValidator->_call('unifyDataType', 'int'));
-               $this->assertEquals('Text', $mockValidator->_call('unifyDataType', 'string'));
+               $this->assertEquals('String', $mockValidator->_call('unifyDataType', 'string'));
                $this->assertEquals('Array', $mockValidator->_call('unifyDataType', 'array'));
                $this->assertEquals('Float', $mockValidator->_call('unifyDataType', 'float'));
                $this->assertEquals('Float', $mockValidator->_call('unifyDataType', 'double'));
@@ -321,8 +329,10 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
 
        /**
         * @test
+        * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function unifyDataTypeRenamesMixedToRaw() {
+               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
                $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'), array($mockObjectManager), '', FALSE);
                $this->assertEquals('Raw', $mockValidator->_call('unifyDataType', 'mixed'));
        }