41 $this->configurationManager = $this->getMock(
'TYPO3\CMS\Extbase\Configuration\ConfigurationManager', array(
'isFeatureEnabled'), array(),
'', FALSE);
42 $this->configurationManager->expects($this->any())->method(
'isFeatureEnabled')->with(
'rewrittenPropertyMapper')->will($this->returnValue(TRUE));
43 $this->validator->injectConfigurationManager($this->configurationManager);
51 $this->assertTrue($this->validator->validate(
'foo')->hasErrors());
59 $this->assertFalse($this->validator->validate(NULL)->hasErrors());
66 $error1 = new \TYPO3\CMS\Extbase\Error\Error(
'error1', 1);
67 $error2 = new \TYPO3\CMS\Extbase\Error\Error(
'error2', 2);
68 $emptyResult1 = new \TYPO3\CMS\Extbase\Error\Result();
69 $emptyResult2 = new \TYPO3\CMS\Extbase\Error\Result();
70 $resultWithError1 = new \TYPO3\CMS\Extbase\Error\Result();
71 $resultWithError1->addError($error1);
72 $resultWithError2 = new \TYPO3\CMS\Extbase\Error\Result();
73 $resultWithError2->addError($error2);
74 $classNameForObjectWithPrivateProperties = $this->
getUniqueId(
'B');
75 eval(
'class ' . $classNameForObjectWithPrivateProperties .
'{ protected $foo = \'foovalue\'; protected $bar = \'barvalue\'; }');
76 $objectWithPrivateProperties =
new $classNameForObjectWithPrivateProperties();
79 array($objectWithPrivateProperties, $emptyResult1, $emptyResult2, array()),
81 array($objectWithPrivateProperties, $resultWithError1, $resultWithError2, array(
'foo' => array($error1),
'bar' => array($error2)))
95 $validatorForFoo = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(
'validate'));
96 $validatorForFoo->expects($this->once())->method(
'validate')->with(
'foovalue')->will($this->returnValue($validationResultForFoo));
97 $validatorForBar = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(
'validate'));
98 $validatorForBar->expects($this->once())->method(
'validate')->with(
'barvalue')->will($this->returnValue($validationResultForBar));
99 $this->validator->addPropertyValidator(
'foo', $validatorForFoo);
100 $this->validator->addPropertyValidator(
'bar', $validatorForBar);
101 $this->assertEquals($errors, $this->validator->validate($mockObject)->getFlattenedErrors());
110 eval(
'class ' . $classNameA .
'{ public $b; }');
112 eval(
'class ' . $classNameB .
'{ public $a; }');
113 $A =
new $classNameA();
114 $B =
new $classNameB();
118 $aValidator = new \TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator(array());
119 $bValidator = new \TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator(array());
121 $aValidator->injectConfigurationManager($this->configurationManager);
122 $bValidator->injectConfigurationManager($this->configurationManager);
124 $aValidator->addPropertyValidator(
'b', $bValidator);
125 $bValidator->addPropertyValidator(
'a', $aValidator);
126 $this->assertFalse($aValidator->validate($A)->hasErrors());
135 eval(
'class ' . $classNameA .
'{ public $b; }');
137 eval(
'class ' . $classNameB .
'{ public $a; public $uuid = 0xF; }');
138 $A =
new $classNameA();
139 $B =
new $classNameB();
145 $aValidator->injectConfigurationManager($this->configurationManager);
146 $bValidator->injectConfigurationManager($this->configurationManager);
148 $aValidator->addPropertyValidator(
'b', $bValidator);
149 $bValidator->addPropertyValidator(
'a', $aValidator);
150 $error = new \TYPO3\CMS\Extbase\Error\Error(
'error1', 123);
151 $result = new \TYPO3\CMS\Extbase\Error\Result();
153 $mockUuidValidator = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(
'validate'));
154 $mockUuidValidator->expects($this->any())->method(
'validate')->with(15)->will($this->returnValue(
$result));
155 $bValidator->addPropertyValidator(
'uuid', $mockUuidValidator);
156 $this->assertSame(array(
'b.uuid' => array($error)), $aValidator->validate($A)->getFlattenedErrors());
165 eval(
'class ' . $classNameA .
'{ public $b; public $uuid = 0xF; }');
167 eval(
'class ' . $classNameB .
'{ public $a; public $uuid = 0xF; }');
168 $A =
new $classNameA();
169 $B =
new $classNameB();
175 $aValidator->injectConfigurationManager($this->configurationManager);
176 $bValidator->injectConfigurationManager($this->configurationManager);
178 $aValidator->addPropertyValidator(
'b', $bValidator);
179 $bValidator->addPropertyValidator(
'a', $aValidator);
180 $error1 = new \TYPO3\CMS\Extbase\Error\Error(
'error1', 123);
181 $result1 = new \TYPO3\CMS\Extbase\Error\Result();
182 $result1->addError($error1);
183 $mockUuidValidator = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(
'validate'));
184 $mockUuidValidator->expects($this->any())->method(
'validate')->with(15)->will($this->returnValue($result1));
185 $aValidator->addPropertyValidator(
'uuid', $mockUuidValidator);
186 $bValidator->addPropertyValidator(
'uuid', $mockUuidValidator);
187 $this->assertSame(array(
'b.uuid' => array($error1),
'uuid' => array($error1)), $aValidator->validate($A)->getFlattenedErrors());
validateChecksAllPropertiesForWhichAPropertyValidatorExists($mockObject, $validationResultForFoo, $validationResultForBar, $errors)
dataProviderForValidator()
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
validatorShouldReturnErrorsIfTheValueIsNoObjectAndNotNull()
getValidator($options=array())
validatorShouldReturnNoErrorsIfTheValueIsNull()
validateDetectsFailuresInRecursiveTargetsI()
validateCanHandleRecursiveTargetsWithoutEndlessLooping()
validateDetectsFailuresInRecursiveTargetsII()