TYPO3 CMS  TYPO3_6-2
ValidatorResolverTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $validatorResolver;
26 
30  protected $mockObjectManager;
31 
32  public function setUp() {
33  $this->validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('dummy'));
34  $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
35  $this->validatorResolver->_set('objectManager', $this->mockObjectManager);
36  }
37 
38  /****************/
39 
44  $extensionName = 'tx_foo';
45  $className = $this->getUniqueId('Foo');
46  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
47  $validatorName = $extensionName . ':' . $className;
48  eval('class ' . $realClassName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {}');
49  $this->assertEquals($realClassName, $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName));
50  }
51 
56  $className = $this->getUniqueId('Foo');
57  $validatorName = 'tx_foo:' . $className;
58  $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\NoSuchValidatorException', '', 1365799920);
59  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
60  }
61 
66  $extensionName = 'tx_foo';
67  $className = $this->getUniqueId('Foo');
68  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
69  $validatorName = $extensionName . ':' . $className;
70  eval('class ' . $realClassName . '{}');
71  $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\NoSuchValidatorException', '', 1365776838);
72  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
73  }
74 
75  /****************/
76 
81  $className = $this->getUniqueId('Foo_');
82  $expectedValidatorName = $className . 'Validator';
83  eval('class ' . $expectedValidatorName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {}');
84  $this->assertEquals(
85  $expectedValidatorName,
86  $this->validatorResolver->_call('resolveValidatorObjectName', $className)
87  );
88  }
89 
94  $className = $this->getUniqueId('Foo');
95  $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\NoSuchValidatorException', '', 1365799920);
96  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
97  }
98 
103  $className = $this->getUniqueId('Foo_');
104  $expectedValidatorName = $className . 'Validator';
105  eval('class ' . $expectedValidatorName . '{}');
106  $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\NoSuchValidatorException', '', 1365776838);
107  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
108  }
109 
110  /****************/
111 
116  return array(
117  array('TYPO3\\CMS\\Mypkg\\Validation\\Validator', 'MySecondValidator', 'TYPO3.CMS.Mypkg:MySecond'),
118  array('Acme\\Mypkg\\Validation\\Validator', 'MyThirdValidator', 'Acme.Mypkg:MyThird')
119  );
120  }
121 
130  public function resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname) {
131  eval('namespace ' . $namespace . '; class ' . $className . ' implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {}');
132  $this->assertSame($namespace . '\\' . $className, $this->validatorResolver->_call('resolveValidatorObjectName', $shorthandValidatorname));
133  }
134 
139  eval('namespace TYPO3\\CMS\\Extbase\\Validation\\Validator;' . LF . 'class FooValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {}');
140  $this->assertSame('TYPO3\\CMS\\Extbase\\Validation\\Validator\\FooValidator', $this->validatorResolver->_call('resolveValidatorObjectName', 'Foo'));
141  }
142 
147  $className = $this->getUniqueId('Test');
148  $validatorOptions = array('requiredOption' => 'foo', 'demoOption' => 'bar');
149  $mockValidator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractValidatorClass', array('dummy'), array($validatorOptions), $className);
150  $this->mockObjectManager->expects($this->any())->method('get')->with($className, $validatorOptions)->will($this->returnValue($mockValidator));
151  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('resolveValidatorObjectName'));
152  $validatorResolver->_set('objectManager', $this->mockObjectManager);
153  $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($className)->will($this->returnValue($className));
154  $validator = $validatorResolver->createValidator($className, $validatorOptions);
155  $this->assertEquals($validatorOptions, $validator->_get('options'));
156  $this->assertSame($mockValidator, $validator);
157  }
158 
163  $this->markTestSkipped('');
164  $className = $this->getUniqueId('Test');
165  $this->setExpectedException('\\TYPO3\\CMS\\Extbase\\Validation\\Exception\NoSuchValidatorException', '', 1365799920);
166  $this->validatorResolver->createValidator($className);
167  }
168 
173  $this->markTestSkipped('Functionality is different now.');
174  $mockConjunctionValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE);
175  $validatorResolver = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('buildBaseValidatorConjunction'), array(), '', FALSE);
176  $validatorResolver->expects($this->once())->method('buildBaseValidatorConjunction')->with('Tx_Virtual_Foo')->will($this->returnValue($mockConjunctionValidator));
177  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
178  $this->assertSame($mockConjunctionValidator, $result, '#1');
179  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
180  $this->assertSame($mockConjunctionValidator, $result, '#2');
181  }
182 
188  $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction'), array(), '', FALSE);
189  $methodParameters = array();
190  $mockReflectionService = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(), '', FALSE);
191  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
192  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('createValidator'));
193  $validatorResolver->_set('reflectionService', $mockReflectionService);
194  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
195  $this->assertSame(array(), $result);
196  }
197 
204  $mockObject = $this->getMock('stdClass', array('fooMethod'), array(), '', FALSE);
205  $methodParameters = array(
206  'arg1' => array(
207  'type' => 'string'
208  ),
209  'arg2' => array(
210  'type' => 'array'
211  )
212  );
213  $methodTagsValues = array(
214  'param' => array(
215  'string $arg1',
216  'array $arg2'
217  ),
218  'validate' => array(
219  '$arg1 Foo(bar = baz), Bar',
220  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
221  )
222  );
223  $mockReflectionService = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(), '', FALSE);
224  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
225  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
226  $mockStringValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
227  $mockArrayValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
228  $mockFooValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
229  $mockBarValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
230  $mockQuuxValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
231  $conjunction1 = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE);
232  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
233  $conjunction1->expects($this->at(1))->method('addValidator')->with($mockFooValidator);
234  $conjunction1->expects($this->at(2))->method('addValidator')->with($mockBarValidator);
235  $conjunction2 = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE);
236  $conjunction2->expects($this->at(0))->method('addValidator')->with($mockArrayValidator);
237  $conjunction2->expects($this->at(1))->method('addValidator')->with($mockQuuxValidator);
238  $mockArguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
239  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg1', 'dummyValue'));
240  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg2', 'dummyValue'));
241  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('createValidator'));
242  $validatorResolver->expects($this->at(0))->method('createValidator')->with('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator')->will($this->returnValue($conjunction1));
243  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
244  $validatorResolver->expects($this->at(2))->method('createValidator')->with('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator')->will($this->returnValue($conjunction2));
245  $validatorResolver->expects($this->at(3))->method('createValidator')->with('array')->will($this->returnValue($mockArrayValidator));
246  $validatorResolver->expects($this->at(4))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockFooValidator));
247  $validatorResolver->expects($this->at(5))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
248  $validatorResolver->expects($this->at(6))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
249  $validatorResolver->_set('reflectionService', $mockReflectionService);
250  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
251  $this->assertEquals(array('arg1' => $conjunction1, 'arg2' => $conjunction2), $result);
252  }
253 
260  $mockObject = $this->getMock('stdClass', array('fooMethod'), array(), '', FALSE);
261  $methodParameters = array(
262  'arg1' => array(
263  'type' => 'string'
264  )
265  );
266  $methodTagsValues = array(
267  'param' => array(
268  'string $arg1'
269  ),
270  'validate' => array(
271  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
272  )
273  );
274  $mockReflectionService = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(), '', FALSE);
275  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
276  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
277  $mockStringValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
278  $mockQuuxValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(), array(), '', FALSE);
279  $conjunction1 = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE);
280  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
281  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('createValidator'));
282  $validatorResolver->expects($this->at(0))->method('createValidator')->with('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator')->will($this->returnValue($conjunction1));
283  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
284  $validatorResolver->expects($this->at(2))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
285  $validatorResolver->_set('reflectionService', $mockReflectionService);
286  $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
287  }
288 
295  $mockObject = $this->getMock('stdClass');
296  $className = get_class($mockObject);
297  $propertyTagsValues = array(
298  'foo' => array(
299  'var' => array('string'),
300  'validate' => array(
301  'Foo(bar= baz), Bar',
302  'Baz'
303  )
304  ),
305  'bar' => array(
306  'var' => array('integer'),
307  'validate' => array(
308  'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'
309  )
310  )
311  );
312 
313  $mockReflectionService = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(), '', FALSE);
314  $mockReflectionService->expects($this->at(0))->method('getClassPropertyNames')->with($className)->will($this->returnValue(array('foo', 'bar')));
315  $mockReflectionService->expects($this->at(1))->method('getPropertyTagsValues')->with($className, 'foo')->will($this->returnValue($propertyTagsValues['foo']));
316  $mockReflectionService->expects($this->at(2))->method('getPropertyTagsValues')->with($className, 'bar')->will($this->returnValue($propertyTagsValues['bar']));
317  $mockObjectValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\GenericObjectValidator', array('dummy'), array(), '', FALSE);
318  $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(), '', FALSE);
319  $mockObjectManager->expects($this->at(0))->method('get')->with('TYPO3\\CMS\\Extbase\\Validation\\Validator\\GenericObjectValidator')->will($this->returnValue($mockObjectValidator));
320  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('resolveValidatorObjectName', 'createValidator'));
321  $validatorResolver->_set('reflectionService', $mockReflectionService);
322  $validatorResolver->_set('objectManager', $mockObjectManager);
323  $validatorResolver->expects($this->at(0))->method('createValidator')->with('Foo', array('bar' => 'baz'))->will($this->returnValue($mockObjectValidator));
324  $validatorResolver->expects($this->at(1))->method('createValidator')->with('Bar')->will($this->returnValue($mockObjectValidator));
325  $validatorResolver->expects($this->at(2))->method('createValidator')->with('Baz')->will($this->returnValue($mockObjectValidator));
326  $validatorResolver->expects($this->at(3))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator')->will($this->returnValue($mockObjectValidator));
327  $validatorResolver->_call('buildBaseValidatorConjunction', $className, $className);
328  }
329 
335  public function modelNamesProvider() {
336  return array(
337  'no replace' => array('VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'),
338  'replace in not namespaced class' => array('Tx_ModelCollection_Domain_Model_Model', 'Tx_ModelCollection_Domain_Validator_ModelValidator'),
339  'replace in namespaced class' => array('VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator')
340  );
341  }
342 
350  public function buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName) {
351  $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(), '', FALSE);
352  $validatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('resolveValidatorObjectName', 'createValidator'));
353  $validatorResolver->_set('objectManager', $mockObjectManager);
354  $validatorResolver->expects($this->once())->method('createValidator')->with($validatorClassName)->will($this->returnValue(NULL));
355  $validatorResolver->_call('buildBaseValidatorConjunction', $modelClassName, $modelClassName);
356  }
357 
363  $validatorName = $this->getUniqueId('FooValidator');
364  eval('namespace TYPO3\CMS\Extbase\Validation\Validator;' . LF . 'class ' . $validatorName . 'Validator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {}');
365  $mockValidatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('getValidatorType'));
366  $mockValidatorResolver->expects($this->once())->method('getValidatorType')->with($validatorName)->will($this->returnValue($validatorName));
367 
368  $mockValidatorResolver->_call('resolveValidatorObjectName', $validatorName);
369  }
370 
376  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'integer'));
377  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'int'));
378  $this->assertEquals('String', $this->validatorResolver->_call('getValidatorType', 'string'));
379  $this->assertEquals('Array', $this->validatorResolver->_call('getValidatorType', 'array'));
380  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'float'));
381  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'double'));
382  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'boolean'));
383  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
384  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
385  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'number'));
386  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'numeric'));
387  }
388 
394  $this->assertEquals('Raw', $this->validatorResolver->_call('getValidatorType', 'mixed'));
395  }
396 
404  public function validatorAnnotations() {
405  return array(
406  array(
407  '$var Bar',
408  array(
409  'argumentName' => 'var',
410  'validators' => array(
411  array('validatorName' => 'Bar', 'validatorOptions' => array())
412  )
413  )
414  ),
415  array(
416  '$var Bar, Foo',
417  array(
418  'argumentName' => 'var',
419  'validators' => array(
420  array('validatorName' => 'Bar', 'validatorOptions' => array()),
421  array('validatorName' => 'Foo', 'validatorOptions' => array())
422  )
423  )
424  ),
425  array(
426  '$var Baz (Foo=Bar)',
427  array(
428  'argumentName' => 'var',
429  'validators' => array(
430  array('validatorName' => 'Baz', 'validatorOptions' => array('Foo' => 'Bar'))
431  )
432  )
433  ),
434  array(
435  '$var Buzz (Foo="B=a, r", Baz=1)',
436  array(
437  'argumentName' => 'var',
438  'validators' => array(
439  array('validatorName' => 'Buzz', 'validatorOptions' => array('Foo' => 'B=a, r', 'Baz' => '1'))
440  )
441  )
442  ),
443  array(
444  '$var Foo(Baz=1, Bar=Quux)',
445  array(
446  'argumentName' => 'var',
447  'validators' => array(
448  array('validatorName' => 'Foo', 'validatorOptions' => array('Baz' => '1', 'Bar' => 'Quux'))
449  )
450  )
451  ),
452  array(
453  '$var Pax, Foo(Baz = \'1\', Bar = Quux)',
454  array(
455  'argumentName' => 'var',
456  'validators' => array(
457  array('validatorName' => 'Pax', 'validatorOptions' => array()),
458  array('validatorName' => 'Foo', 'validatorOptions' => array('Baz' => '1', 'Bar' => 'Quux'))
459  )
460  )
461  ),
462  array(
463  '$var Reg (P="[at]*(h|g)"), Quux',
464  array(
465  'argumentName' => 'var',
466  'validators' => array(
467  array('validatorName' => 'Reg', 'validatorOptions' => array('P' => '[at]*(h|g)')),
468  array('validatorName' => 'Quux', 'validatorOptions' => array())
469  )
470  )
471  ),
472  array(
473  '$var Baz (Foo="B\\"ar")',
474  array(
475  'argumentName' => 'var',
476  'validators' => array(
477  array('validatorName' => 'Baz', 'validatorOptions' => array('Foo' => 'B"ar'))
478  )
479  )
480  ),
481  array(
482  '$var F3_TestPackage_Quux',
483  array(
484  'argumentName' => 'var',
485  'validators' => array(
486  array('validatorName' => 'F3_TestPackage_Quux', 'validatorOptions' => array())
487  )
488  )
489  ),
490  array(
491  '$var Baz(Foo="5"), Bar(Quux="123")',
492  array(
493  'argumentName' => 'var',
494  'validators' => array(
495  array('validatorName' => 'Baz', 'validatorOptions' => array('Foo' => '5')),
496  array('validatorName' => 'Bar', 'validatorOptions' => array('Quux' => '123'))
497  )
498  )
499  ),
500  array(
501  '$var Baz(Foo="2"), Bar(Quux=123, Pax="a weird \\"string\\" with *freaky* \\stuff")',
502  array(
503  'argumentName' => 'var',
504  'validators' => array(
505  array('validatorName' => 'Baz', 'validatorOptions' => array('Foo' => '2')),
506  array('validatorName' => 'Bar', 'validatorOptions' => array('Quux' => '123', 'Pax' => 'a weird "string" with *freaky* \\stuff'))
507  )
508  )
509  ),
510  'namespaced validator class name' => array(
511  'annotation' => '$var F3\TestPackage\Quux',
512  'expected' => array(
513  'argumentName' => 'var',
514  'validators' => array(
515  array('validatorName' => 'F3\TestPackage\Quux', 'validatorOptions' => array())
516  )
517  )
518  ),
519  'shorthand notation for system validator' => array(
520  'annotation' => '$var TYPO3.CMS.Mypkg:MySecond',
521  'expected' => array(
522  'argumentName' => 'var',
523  'validators' => array(
524  array('validatorName' => 'TYPO3.CMS.Mypkg:MySecond', 'validatorOptions' => array())
525  )
526  )
527  ),
528  'shorthand notation for custom validator with parameter' => array(
529  'annotation' => '$var Acme.Mypkg:MyThird(Foo="2")',
530  'expected' => array(
531  'argumentName' => 'var',
532  'validators' => array(
533  array('validatorName' => 'Acme.Mypkg:MyThird', 'validatorOptions' => array('Foo' => '2'))
534  )
535  )
536  ),
537  );
538  }
539 
547  public function parseValidatorAnnotationCanParseAnnotations($annotation, $expectedResult) {
548  $result = $this->validatorResolver->_call('parseValidatorAnnotation', $annotation);
549  $this->assertEquals($result, $expectedResult);
550  }
551 }
buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname)