[FEATURE] Add getValidators to AbstractCompositeValidator 73/23573/3
authorStefan Froemken <froemken@gmail.com>
Wed, 4 Sep 2013 07:09:14 +0000 (09:09 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 14 Oct 2013 22:54:09 +0000 (00:54 +0200)
removeValidator is unusable as long as there is no method
to get contained validators

Resolves: #51707
Releases: 6.2, 6.1, 6.0
Change-Id: If8705e8b5c7c2dfa84a732b97813d6097930f209
Reviewed-on: https://review.typo3.org/23573
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extbase/Classes/Validation/Validator/AbstractCompositeValidator.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/ConjunctionValidatorTest.php

index fc98578..051be72 100644 (file)
@@ -108,6 +108,15 @@ abstract class AbstractCompositeValidator implements \TYPO3\CMS\Extbase\Validati
        public function count() {
                return count($this->validators);
        }
+
+       /**
+        * Returns the child validators of this Composite Validator
+        *
+        * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
+        */
+       public function getValidators() {
+               return $this->validators;
+       }
 }
 
 ?>
\ No newline at end of file
index ecd6f4d..cd3820b 100644 (file)
@@ -36,7 +36,7 @@ class ConjunctionValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCas
                $conjunctionValidator = new $proxyClassName(array());
                $mockValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface');
                $conjunctionValidator->addValidator($mockValidator);
-               $this->assertTrue($conjunctionValidator->_get('validators')->contains($mockValidator));
+               $this->assertTrue($conjunctionValidator->getValidators()->contains($mockValidator));
        }
 
        /**
@@ -103,8 +103,8 @@ class ConjunctionValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCas
                $validatorConjunction->addValidator($validator1);
                $validatorConjunction->addValidator($validator2);
                $validatorConjunction->removeValidator($validator1);
-               $this->assertFalse($validatorConjunction->_get('validators')->contains($validator1));
-               $this->assertTrue($validatorConjunction->_get('validators')->contains($validator2));
+               $this->assertFalse($validatorConjunction->getValidators()->contains($validator1));
+               $this->assertTrue($validatorConjunction->getValidators()->contains($validator2));
        }
 
        /**