Revert "[BUGFIX] Correctly apply Extbase-validator-options / Add tests" 99/25299/2
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 12 Nov 2013 10:47:45 +0000 (11:47 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 12 Nov 2013 10:48:12 +0000 (11:48 +0100)
This reverts commit 742a5dff0acc5c931793396421076ff2fc22edda

Change-Id: Ia68211d95f6181f54675614fc26d019118c3e176
Reviewed-on: https://review.typo3.org/25299
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
18 files changed:
typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php
typo3/sysext/extbase/Classes/Validation/Validator/BooleanValidator.php
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractCompositeValidatorTest.php [deleted file]
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractValidatorTest.php [deleted file]
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractValidatorTestcase.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AlphanumericValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/EmailAddressValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractCompositeValidatorClass.php [deleted file]
typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractValidatorClass.php [deleted file]
typo3/sysext/extbase/Tests/Unit/Validation/Validator/FloatValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/GenericObjectValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/IntegerValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/NotEmptyValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/StringLengthValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/StringValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/TextValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php

index 851921b..82a7771 100644 (file)
@@ -67,39 +67,13 @@ abstract class AbstractValidator implements \TYPO3\CMS\Extbase\Validation\Valida
        protected $result;
 
        /**
-        * Constructs the composite validator and sets validation options
+        * Sets options for the validator
         *
-        * @param array $options Options for the validator
-        * @throws \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
+        * @param array $validationOptions Options for the validator
         * @api
         */
-       public function __construct(array $options = array()) {
-               // check for options given but not supported
-               if (($unsupportedOptions = array_diff_key($options, $this->supportedOptions)) !== array()) {
-                       throw new \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException('Unsupported validation option(s) found: ' . implode(', ', array_keys($unsupportedOptions)), 1379981890);
-               }
-
-               // check for required options being set
-               array_walk(
-                       $this->supportedOptions,
-                       function($supportedOptionData, $supportedOptionName, $options) {
-                               if (isset($supportedOptionData[3]) && !array_key_exists($supportedOptionName, $options)) {
-                                       throw new \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException('Required validation option not set: ' . $supportedOptionName, 1379981891);
-                               }
-                       },
-                       $options
-               );
-
-               // merge with default values
-               $this->options = array_merge(
-                       array_map(
-                               function ($value) {
-                                       return $value[0];
-                               },
-                               $this->supportedOptions
-                       ),
-                       $options
-               );
+       public function __construct($validationOptions = array()) {
+               $this->options = $validationOptions;
        }
 
        /**
index afb3569..029309e 100644 (file)
@@ -32,13 +32,6 @@ namespace TYPO3\CMS\Extbase\Validation\Validator;
  */
 class BooleanValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator {
 
-        /**
-         * @var array
-         */
-        protected $supportedOptions = array(
-                'is' => array(TRUE, 'Boolean value', 'boolean|string|integer')
-        );
-
        /**
         * Returns TRUE if the given property value is a boolean matching the expectation.
         *
@@ -51,6 +44,9 @@ class BooleanValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractV
         * @return boolean TRUE if the value is within the range, otherwise FALSE
         */
        public function isValid($value) {
+               if (!isset($this->options['is'])) {
+                       return;
+               }
                switch (strtolower((string)$this->options['is'])) {
                        case 'true':
                        case '1':
index 8f3206c..23c11a3 100644 (file)
@@ -105,7 +105,11 @@ class ValidatorResolver implements \TYPO3\CMS\Core\SingletonInterface {
                         */
                        $validatorObjectName = $this->resolveValidatorObjectName($validatorType);
 
-                       $validator = $this->objectManager->get($validatorObjectName, $validatorOptions);
+                       $validator = $this->objectManager->get($validatorObjectName);
+                       if (method_exists($validator, 'setOptions')) {
+                               // @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1
+                               $validator->setOptions($validatorOptions);
+                       }
 
                        if (!($validator instanceof \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface)) {
                                throw new Exception\NoSuchValidatorException('The validator "' . $validatorObjectName . '" does not implement TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface!', 1300694875);
diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractCompositeValidatorTest.php b/typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractCompositeValidatorTest.php
deleted file mode 100644 (file)
index 630701f..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator;
-
-/*                                                                        *
- * This script belongs to the Extbase framework.                            *
- *                                                                        *
- * 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!                         *
- *                                                                        */
-
-/**
- * Testcase for the abstract base-class of composite-validators
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class AbstractCompositeValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
-
-       /**
-        * @test
-        */
-       public function validatorAcceptsSupportedOptions() {
-               $inputOptions = array(
-                       'requiredOption' => 666,
-                       'demoOption' => 42
-               );
-               $expectedOptions = $inputOptions;
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
-               $this->assertSame($expectedOptions, $validator->_get('options'));
-       }
-
-       /**
-        * @test
-        */
-       public function validatorHasDefaultOptions() {
-               $inputOptions = array('requiredOption' => 666);
-               $expectedOptions = array(
-                       'requiredOption' => 666,
-                       'demoOption' => PHP_INT_MAX
-               );
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
-               $this->assertSame($expectedOptions, $validator->_get('options'));
-       }
-
-       /**
-        * @test
-        */
-       public function validatorThrowsExceptionOnNotSupportedOptions() {
-               $inputOptions = array('invalidoption' => 42);
-               $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1339079804);
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
-       }
-
-
-       /**
-        * @test
-        */
-       public function validatorThrowsExceptionOnMissingRequiredOptions() {
-               $inputOptions = array();
-               $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1339163922);
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractValidatorTest.php b/typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractValidatorTest.php
deleted file mode 100644 (file)
index d4efbe1..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator;
-
-/*                                                                        *
- * This script belongs to the Extbase framework.                            *
- *                                                                        *
- * 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!                         *
- *                                                                        */
-
-/**
- * Testcase for the abstract base-class of validators
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class AbstractValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
-
-       /**
-        * @test
-        */
-       public function validatorAcceptsSupportedOptions() {
-               $inputOptions = array(
-                       'requiredOption' => 666,
-                       'demoOption' => 42
-               );
-               $expectedOptions = $inputOptions;
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($inputOptions));
-               $this->assertSame($expectedOptions, $validator->_get('options'));
-       }
-
-       /**
-        * @test
-        */
-       public function validatorHasDefaultOptions() {
-               $inputOptions = array('requiredOption' => 666);
-               $expectedOptions = array(
-                       'requiredOption' => 666,
-                       'demoOption' => PHP_INT_MAX
-               );
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($inputOptions));
-               $this->assertSame($expectedOptions, $validator->_get('options'));
-       }
-
-       /**
-        * @test
-        */
-       public function validatorThrowsExceptionOnNotSupportedOptions() {
-               $inputOptions = array('invalidoption' => 42);
-               $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1379981890);
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($inputOptions));
-       }
-
-
-       /**
-        * @test
-        */
-       public function validatorThrowsExceptionOnMissingRequiredOptions() {
-               $inputOptions = array();
-               $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1379981891);
-               $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($inputOptions));
-       }
-
-}
-
-?>
\ No newline at end of file
index 8f6ed55..e38dba8 100644 (file)
@@ -34,6 +34,10 @@ abstract class AbstractValidatorTestcase extends \TYPO3\CMS\Extbase\Tests\Unit\B
         */
        protected $validator;
 
+       public function setUp() {
+               $this->validator = $this->getValidator();
+       }
+
        /**
         * @param array $options
         * @return mixed
index d2f5054..00d57f3 100644 (file)
@@ -30,10 +30,6 @@ class AlphanumericValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\AlphanumericValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * @test
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
index 991e23d..fbe4da3 100644 (file)
@@ -30,10 +30,6 @@ class EmailAddressValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\EmailAddressValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * Data provider with valid email addresses
         *
diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractCompositeValidatorClass.php b/typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractCompositeValidatorClass.php
deleted file mode 100644 (file)
index a5e1b0d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture;
-
-/*                                                                        *
- * This script belongs to the Extbase framework.                            *
- *                                                                        *
- * 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!                         *
- *                                                                        */
-
-/**
- * Testcase for the abstract base-class of vvalidators
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class AbstractCompositeValidatorClass extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractCompositeValidator {
-
-       /**
-        * @var array
-        */
-       protected $supportedOptions = array(
-               'requiredOption' => array(0, 'Some value', 'integer', TRUE),
-               'demoOption' => array(PHP_INT_MAX, 'Some value', 'integer'),
-       );
-
-       /**
-        * Check if $value is valid. If it is not valid, needs to add an error
-        * to Result.
-        *
-        * @param mixed $value
-        * @return void
-        */
-       protected function isValid($value) {
-               // dummy
-       }
-
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractValidatorClass.php b/typo3/sysext/extbase/Tests/Unit/Validation/Validator/Fixture/AbstractValidatorClass.php
deleted file mode 100644 (file)
index f1b1713..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture;
-
-/*                                                                        *
- * This script belongs to the Extbase framework.                            *
- *                                                                        *
- * 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!                         *
- *                                                                        */
-
-/**
- * Testcase for the abstract base-class of vvalidators
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class AbstractValidatorClass extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator {
-
-       /**
-        * @var array
-        */
-       protected $supportedOptions = array(
-               'requiredOption' => array(0, 'Some value', 'integer', TRUE),
-               'demoOption' => array(PHP_INT_MAX, 'Some value', 'integer'),
-       );
-
-       /**
-        * Check if $value is valid. If it is not valid, needs to add an error
-        * to Result.
-        *
-        * @param mixed $value
-        * @return void
-        */
-       protected function isValid($value) {
-               // dummy
-       }
-
-
-}
-?>
\ No newline at end of file
index 9b256ef..0fcd973 100644 (file)
@@ -30,10 +30,6 @@ class FloatValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Valida
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\FloatValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * Data provider with valid floats
         *
index fed0bd0..fcbe0ac 100644 (file)
@@ -36,7 +36,7 @@ class GenericObjectValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validatio
        protected $configurationManager;
 
        public function setUp() {
-               $this->validator = $this->getValidator();
+               parent::setUp();
 
                $this->configurationManager = $this->getMock('TYPO3\CMS\Extbase\Configuration\ConfigurationManager', array('isFeatureEnabled'), array(), '', FALSE);
                $this->configurationManager->expects($this->any())->method('isFeatureEnabled')->with('rewrittenPropertyMapper')->will($this->returnValue(TRUE));
index b450754..8d46cde 100644 (file)
@@ -30,10 +30,6 @@ class IntegerValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Vali
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\IntegerValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * Data provider with valid integers
         *
index 8f68b7a..4de1801 100644 (file)
@@ -30,10 +30,6 @@ class NotEmptyValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Val
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * @test
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
index a892724..9ad776b 100644 (file)
@@ -30,9 +30,10 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\StringLengthValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
+       /**
+        * @var \TYPO3\Flow\Validation\Validator\StringLengthValidator
+        */
+       protected $validator;
 
        /**
         * @test
@@ -74,6 +75,7 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
 
        /**
         * @test
+        * @expectedException \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
         */
        public function stringLengthValidatorReturnsNoErrorsForAStringLongerThanThanMinLengthAndMaxLengthNotSpecified() {
                $this->validatorOptions(array('minimum' => 5));
@@ -98,6 +100,7 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
 
        /**
         * @test
+        * @expectedException \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
         */
        public function stringLengthValidatorReturnsNoErrorForAStringLengthEqualToMinLengthAndMaxLengthNotSpecified() {
                $this->validatorOptions(array('minimum' => 10));
@@ -133,6 +136,7 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
         * @expectedException \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
         */
        public function stringLengthValidatorThrowsAnExceptionIfMinLengthIsGreaterThanMaxLength() {
+               $this->validator = $this->getMock('TYPO3\Flow\Validation\Validator\StringLengthValidator', array('addError'), array(), '', FALSE);
                $this->validatorOptions(array('minimum' => 101, 'maximum' => 100));
                $this->validator->validate('1234567890');
        }
@@ -150,6 +154,7 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
         * @test
         */
        public function stringLengthValidatorCanHandleAnObjectWithAToStringMethod() {
+               $this->validator = $this->getMock('TYPO3\Flow\Validation\Validator\StringLengthValidator', array('addError'), array(), '', FALSE);
                $this->validatorOptions(array('minimum' => 5, 'maximum' => 100));
 
                $className = 'TestClass' . md5(uniqid(mt_rand(), TRUE));
@@ -170,6 +175,7 @@ class StringLengthValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation
         * @test
         */
        public function validateReturnsErrorsIfTheGivenObjectCanNotBeConvertedToAString() {
+               $this->validator = $this->getMock('TYPO3\Flow\Validation\Validator\StringLengthValidator', array('addError'), array(), '', FALSE);
                $this->validatorOptions(array('minimum' => 5, 'maximum' => 100));
 
                $className = 'TestClass' . md5(uniqid(mt_rand(), TRUE));
index 537297e..4cfbeb8 100644 (file)
@@ -30,10 +30,6 @@ class StringValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Valid
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\StringValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
index 23b7b68..898ad89 100644 (file)
@@ -30,10 +30,6 @@ class TextValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Validat
 
        protected $validatorClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\TextValidator';
 
-       public function setUp() {
-               $this->validator = $this->getValidator();
-       }
-
        /**
         * @test
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
index 9ab5180..3206bd7 100644 (file)
@@ -158,14 +158,13 @@ class ValidatorResolverTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         */
        public function createValidatorResolvesAndReturnsAValidatorAndPassesTheGivenOptions() {
                $className = uniqid('Test');
-               $validatorOptions = array('requiredOption' => 'foo', 'demoOption' => 'bar');
-               $mockValidator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($validatorOptions), $className);
-               $this->mockObjectManager->expects($this->any())->method('get')->with($className, $validatorOptions)->will($this->returnValue($mockValidator));
+               $mockValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ObjectValidatorInterface', array('setOptions', 'canValidate', 'isPropertyValid', 'setValidatedInstancesContainer'), array(), $className);
+               $mockValidator->expects($this->once())->method('setOptions')->with(array('foo' => 'bar'));
+               $this->mockObjectManager->expects($this->any())->method('get')->with($className)->will($this->returnValue($mockValidator));
                $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('resolveValidatorObjectName'));
                $validatorResolver->_set('objectManager', $this->mockObjectManager);
                $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($className)->will($this->returnValue($className));
-               $validator = $validatorResolver->createValidator($className, $validatorOptions);
-               $this->assertEquals($validatorOptions, $validator->_get('options'));
+               $validator = $validatorResolver->createValidator($className, array('foo' => 'bar'));
                $this->assertSame($mockValidator, $validator);
        }