TYPO3 CMS  TYPO3_8-7
ValidatorResolverTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
23 class ValidatorResolverTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
28  protected $validatorResolver;
29 
33  protected $mockObjectManager;
34 
35  protected function setUp()
36  {
37  $this->validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['dummy']);
38  $this->mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
39  $this->validatorResolver->_set('objectManager', $this->mockObjectManager);
40  }
41 
42  /****************/
43 
48  {
49  $extensionName = 'tx_foo';
50  $className = $this->getUniqueId('Foo');
51  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
52  $validatorName = $extensionName . ':' . $className;
53  eval('class ' . $realClassName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {
54  public function validate($value){} public function getOptions(){}
55  }');
56  $this->assertEquals($realClassName, $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName));
57  }
58 
63  {
64  $className = $this->getUniqueId('Foo');
65  $validatorName = 'tx_foo:' . $className;
66  $this->expectException(NoSuchValidatorException::class);
67  $this->expectExceptionCode(1365799920);
68  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
69  }
70 
75  {
76  $extensionName = 'tx_foo';
77  $className = $this->getUniqueId('Foo');
78  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
79  $validatorName = $extensionName . ':' . $className;
80  eval('class ' . $realClassName . '{}');
81  $this->expectException(NoSuchValidatorException::class);
82  $this->expectExceptionCode(1365776838);
83  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
84  }
85 
86  /****************/
87 
92  {
93  $className = $this->getUniqueId('Foo_');
94  $expectedValidatorName = $className . 'Validator';
95  eval('class ' . $expectedValidatorName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {
96  public function validate($value){} public function getOptions(){}
97  }');
98  $this->assertEquals(
99  $expectedValidatorName,
100  $this->validatorResolver->_call('resolveValidatorObjectName', $className)
101  );
102  }
103 
108  {
109  $className = $this->getUniqueId('Foo');
110  $this->expectException(NoSuchValidatorException::class);
111  $this->expectExceptionCode(1365799920);
112  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
113  }
114 
119  {
120  $className = $this->getUniqueId('Foo_');
121  $expectedValidatorName = $className . 'Validator';
122  eval('class ' . $expectedValidatorName . '{}');
123  $this->expectException(NoSuchValidatorException::class);
124  $this->expectExceptionCode(1365776838);
125  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
126  }
127 
128  /****************/
129 
134  {
135  return [
136  ['TYPO3\\CMS\\Mypkg\\Validation\\Validator', 'MySecondValidator', 'TYPO3.CMS.Mypkg:MySecond'],
137  ['Acme\\Mypkg\\Validation\\Validator', 'MyThirdValidator', 'Acme.Mypkg:MyThird']
138  ];
139  }
140 
149  public function resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname)
150  {
151  eval('namespace ' . $namespace . '; class ' . $className . ' implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
152  public function validate($value){} public function getOptions(){}
153  }');
154  $this->assertSame($namespace . '\\' . $className, $this->validatorResolver->_call('resolveValidatorObjectName', $shorthandValidatorname));
155  }
156 
161  {
162  eval('namespace TYPO3\\CMS\\Extbase\\Validation\\Validator;' . LF . 'class FooValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
163  public function validate($value){} public function getOptions(){}
164  }');
165  $this->assertSame('TYPO3\\CMS\\Extbase\\Validation\\Validator\\FooValidator', $this->validatorResolver->_call('resolveValidatorObjectName', 'Foo'));
166  }
167 
171  public function createValidatorResolvesAndReturnsAValidatorAndPassesTheGivenOptions()
172  {
173  $className = $this->getUniqueId('Test');
174  $mockValidator = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ObjectValidatorInterface::class)
175  ->setMethods(['validate', 'getOptions', 'setValidatedInstancesContainer'])
176  ->setMockClassName($className)
177  ->getMock();
178  $this->mockObjectManager->expects($this->any())->method('get')->with($className)->will($this->returnValue($mockValidator));
180  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName']);
181  $validatorResolver->_set('objectManager', $this->mockObjectManager);
182  $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($className)->will($this->returnValue($className));
183  $validator = $validatorResolver->createValidator($className);
184  $this->assertSame($mockValidator, $validator);
185  }
186 
191  {
192  $this->markTestSkipped('');
193  $className = $this->getUniqueId('Test');
194  $this->expectException(NoSuchValidatorException::class);
195  $this->expectExceptionCode(1365799920);
196  $this->validatorResolver->createValidator($className);
197  }
198 
203  {
204  $this->markTestSkipped('Functionality is different now.');
205  $mockConjunctionValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class);
206  $validatorResolver = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class)
207  ->setMethods(['buildBaseValidatorConjunction'])
208  ->disableOriginalConstructor()
209  ->getMock();
210  $validatorResolver->expects($this->once())->method('buildBaseValidatorConjunction')->with('Tx_Virtual_Foo')->will($this->returnValue($mockConjunctionValidator));
211  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
212  $this->assertSame($mockConjunctionValidator, $result, '#1');
213  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
214  $this->assertSame($mockConjunctionValidator, $result, '#2');
215  }
216 
221  {
222  $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, ['fooAction'], [], '', false);
223  $methodParameters = [];
224  $mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
225  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
226  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
227  $validatorResolver->_set('reflectionService', $mockReflectionService);
228  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
229  $this->assertSame([], $result);
230  }
231 
236  {
237  $mockObject = $this->getMockBuilder('stdClass')
238  ->setMethods(['fooMethod'])
239  ->disableOriginalConstructor()
240  ->getMock();
241  $methodParameters = [
242  'arg1' => [
243  'type' => 'string'
244  ],
245  'arg2' => [
246  'type' => 'array'
247  ]
248  ];
249  $methodTagsValues = [
250  'param' => [
251  'string $arg1',
252  'array $arg2'
253  ],
254  'validate' => [
255  '$arg1 Foo(bar = baz), Bar',
256  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
257  ]
258  ];
259  $mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
260  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
261  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
262  $mockStringValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
263  $mockArrayValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
264  $mockFooValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
265  $mockBarValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
266  $mockQuuxValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
267  $conjunction1 = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class);
268  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
269  $conjunction1->expects($this->at(1))->method('addValidator')->with($mockFooValidator);
270  $conjunction1->expects($this->at(2))->method('addValidator')->with($mockBarValidator);
271  $conjunction2 = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class);
272  $conjunction2->expects($this->at(0))->method('addValidator')->with($mockArrayValidator);
273  $conjunction2->expects($this->at(1))->method('addValidator')->with($mockQuuxValidator);
274  $mockArguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
275  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg1', 'dummyValue'));
276  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg2', 'dummyValue'));
277  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
278  $validatorResolver->expects($this->at(0))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction1));
279  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
280  $validatorResolver->expects($this->at(2))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction2));
281  $validatorResolver->expects($this->at(3))->method('createValidator')->with('array')->will($this->returnValue($mockArrayValidator));
282  $validatorResolver->expects($this->at(4))->method('createValidator')->with('Foo', ['bar' => 'baz'])->will($this->returnValue($mockFooValidator));
283  $validatorResolver->expects($this->at(5))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
284  $validatorResolver->expects($this->at(6))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
285  $validatorResolver->_set('reflectionService', $mockReflectionService);
286  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
287  $this->assertEquals(['arg1' => $conjunction1, 'arg2' => $conjunction2], $result);
288  }
289 
294  {
295  $this->expectException(InvalidValidationConfigurationException::class);
296  $this->expectExceptionCode(1253172726);
297  $mockObject = $this->getMockBuilder('stdClass')
298  ->setMethods(['fooMethod'])
299  ->disableOriginalConstructor()
300  ->getMock();
301  $methodParameters = [
302  'arg1' => [
303  'type' => 'string'
304  ]
305  ];
306  $methodTagsValues = [
307  'param' => [
308  'string $arg1'
309  ],
310  'validate' => [
311  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
312  ]
313  ];
314  $mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
315  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
316  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
317  $mockStringValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
318  $mockQuuxValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
319  $conjunction1 = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class);
320  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
321  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
322  $validatorResolver->expects($this->at(0))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction1));
323  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
324  $validatorResolver->expects($this->at(2))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
325  $validatorResolver->_set('reflectionService', $mockReflectionService);
326  $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
327  }
328 
333  {
334  $mockObject = $this->createMock('stdClass');
335  $className = get_class($mockObject);
336  $propertyTagsValues = [
337  'foo' => [
338  'var' => ['string'],
339  'validate' => [
340  'Foo(bar= baz), Bar',
341  'Baz'
342  ]
343  ],
344  'bar' => [
345  'var' => ['integer'],
346  'validate' => [
347  'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'
348  ]
349  ]
350  ];
351 
352  $mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
353  $mockReflectionService->expects($this->at(0))->method('getClassPropertyNames')->with($className)->will($this->returnValue(['foo', 'bar']));
354  $mockReflectionService->expects($this->at(1))->method('getPropertyTagsValues')->with($className, 'foo')->will($this->returnValue($propertyTagsValues['foo']));
355  $mockReflectionService->expects($this->at(2))->method('getPropertyTagsValues')->with($className, 'bar')->will($this->returnValue($propertyTagsValues['bar']));
356  $mockObjectValidator = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator::class)
357  ->setMethods(['dummy'])
358  ->disableOriginalConstructor()
359  ->getMock();
360  $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
361  $mockObjectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator::class)->will($this->returnValue($mockObjectValidator));
362  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName', 'createValidator']);
363  $validatorResolver->_set('reflectionService', $mockReflectionService);
364  $validatorResolver->_set('objectManager', $mockObjectManager);
365  $validatorResolver->expects($this->at(0))->method('createValidator')->with('Foo', ['bar' => 'baz'])->will($this->returnValue($mockObjectValidator));
366  $validatorResolver->expects($this->at(1))->method('createValidator')->with('Bar')->will($this->returnValue($mockObjectValidator));
367  $validatorResolver->expects($this->at(2))->method('createValidator')->with('Baz')->will($this->returnValue($mockObjectValidator));
368  $validatorResolver->expects($this->at(3))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator')->will($this->returnValue($mockObjectValidator));
369  $validatorResolver->_call('buildBaseValidatorConjunction', $className, $className);
370  }
371 
377  public function modelNamesProvider()
378  {
379  return [
380  'no replace' => ['VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'],
381  'replace in not namespaced class' => ['Tx_ModelCollection_Domain_Model_Model', 'Tx_ModelCollection_Domain_Validator_ModelValidator'],
382  'replace in namespaced class' => ['VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator']
383  ];
384  }
385 
393  public function buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName)
394  {
395  $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
396  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName', 'createValidator']);
397  $validatorResolver->_set('objectManager', $mockObjectManager);
398  $validatorResolver->expects($this->once())->method('createValidator')->with($validatorClassName)->will($this->returnValue(null));
399  $validatorResolver->_call('buildBaseValidatorConjunction', $modelClassName, $modelClassName);
400  }
401 
406  {
407  $validatorName = $this->getUniqueId('FooValidator');
408  eval('namespace TYPO3\CMS\Extbase\Validation\Validator;' . LF . 'class ' . $validatorName . 'Validator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
409  public function validate($value){} public function getOptions(){}
410  }');
411  $mockValidatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['getValidatorType']);
412  $mockValidatorResolver->expects($this->once())->method('getValidatorType')->with($validatorName)->will($this->returnValue($validatorName));
413 
414  $mockValidatorResolver->_call('resolveValidatorObjectName', $validatorName);
415  }
416 
421  {
422  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'integer'));
423  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'int'));
424  $this->assertEquals('String', $this->validatorResolver->_call('getValidatorType', 'string'));
425  $this->assertEquals('Array', $this->validatorResolver->_call('getValidatorType', 'array'));
426  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'float'));
427  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'double'));
428  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'boolean'));
429  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
430  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
431  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'number'));
432  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'numeric'));
433  }
434 
439  {
440  $this->assertEquals('Raw', $this->validatorResolver->_call('getValidatorType', 'mixed'));
441  }
442 
447  public function validatorAnnotations()
448  {
449  return [
450  [
451  '$var Bar',
452  [
453  'argumentName' => 'var',
454  'validators' => [
455  ['validatorName' => 'Bar', 'validatorOptions' => []]
456  ]
457  ]
458  ],
459  [
460  '$var Bar, Foo',
461  [
462  'argumentName' => 'var',
463  'validators' => [
464  ['validatorName' => 'Bar', 'validatorOptions' => []],
465  ['validatorName' => 'Foo', 'validatorOptions' => []]
466  ]
467  ]
468  ],
469  [
470  '$var Baz (Foo=Bar)',
471  [
472  'argumentName' => 'var',
473  'validators' => [
474  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => 'Bar']]
475  ]
476  ]
477  ],
478  [
479  '$var Buzz (Foo="B=a, r", Baz=1)',
480  [
481  'argumentName' => 'var',
482  'validators' => [
483  ['validatorName' => 'Buzz', 'validatorOptions' => ['Foo' => 'B=a, r', 'Baz' => '1']]
484  ]
485  ]
486  ],
487  [
488  '$var Foo(Baz=1, Bar=Quux)',
489  [
490  'argumentName' => 'var',
491  'validators' => [
492  ['validatorName' => 'Foo', 'validatorOptions' => ['Baz' => '1', 'Bar' => 'Quux']]
493  ]
494  ]
495  ],
496  [
497  '$var Pax, Foo(Baz = \'1\', Bar = Quux)',
498  [
499  'argumentName' => 'var',
500  'validators' => [
501  ['validatorName' => 'Pax', 'validatorOptions' => []],
502  ['validatorName' => 'Foo', 'validatorOptions' => ['Baz' => '1', 'Bar' => 'Quux']]
503  ]
504  ]
505  ],
506  [
507  '$var Reg (P="[at]*(h|g)"), Quux',
508  [
509  'argumentName' => 'var',
510  'validators' => [
511  ['validatorName' => 'Reg', 'validatorOptions' => ['P' => '[at]*(h|g)']],
512  ['validatorName' => 'Quux', 'validatorOptions' => []]
513  ]
514  ]
515  ],
516  [
517  '$var Baz (Foo="B\\"ar")',
518  [
519  'argumentName' => 'var',
520  'validators' => [
521  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => 'B"ar']]
522  ]
523  ]
524  ],
525  [
526  '$var F3_TestPackage_Quux',
527  [
528  'argumentName' => 'var',
529  'validators' => [
530  ['validatorName' => 'F3_TestPackage_Quux', 'validatorOptions' => []]
531  ]
532  ]
533  ],
534  [
535  '$var Baz(Foo="5"), Bar(Quux="123")',
536  [
537  'argumentName' => 'var',
538  'validators' => [
539  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => '5']],
540  ['validatorName' => 'Bar', 'validatorOptions' => ['Quux' => '123']]
541  ]
542  ]
543  ],
544  [
545  '$var Baz(Foo="2"), Bar(Quux=123, Pax="a weird \\"string\\" with *freaky* \\stuff")',
546  [
547  'argumentName' => 'var',
548  'validators' => [
549  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => '2']],
550  ['validatorName' => 'Bar', 'validatorOptions' => ['Quux' => '123', 'Pax' => 'a weird "string" with *freaky* \\stuff']]
551  ]
552  ]
553  ],
554  'namespaced validator class name' => [
555  'annotation' => '$var F3\TestPackage\Quux',
556  'expected' => [
557  'argumentName' => 'var',
558  'validators' => [
559  ['validatorName' => 'F3\TestPackage\Quux', 'validatorOptions' => []]
560  ]
561  ]
562  ],
563  'shorthand notation for system validator' => [
564  'annotation' => '$var TYPO3.CMS.Mypkg:MySecond',
565  'expected' => [
566  'argumentName' => 'var',
567  'validators' => [
568  ['validatorName' => 'TYPO3.CMS.Mypkg:MySecond', 'validatorOptions' => []]
569  ]
570  ]
571  ],
572  'shorthand notation for custom validator with parameter' => [
573  'annotation' => '$var Acme.Mypkg:MyThird(Foo="2")',
574  'expected' => [
575  'argumentName' => 'var',
576  'validators' => [
577  ['validatorName' => 'Acme.Mypkg:MyThird', 'validatorOptions' => ['Foo' => '2']]
578  ]
579  ]
580  ],
581  ];
582  }
583 
590  public function parseValidatorAnnotationCanParseAnnotations($annotation, $expectedResult)
591  {
592  $result = $this->validatorResolver->_call('parseValidatorAnnotation', $annotation);
593  $this->assertEquals($result, $expectedResult);
594  }
595 }
buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName)
resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname)