TYPO3 CMS  TYPO3_7-6
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 
21 {
25  protected $validatorResolver;
26 
30  protected $mockObjectManager;
31 
32  protected function setUp()
33  {
34  $this->validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['dummy']);
35  $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
36  $this->validatorResolver->_set('objectManager', $this->mockObjectManager);
37  }
38 
39  /****************/
40 
45  {
46  $extensionName = 'tx_foo';
47  $className = $this->getUniqueId('Foo');
48  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
49  $validatorName = $extensionName . ':' . $className;
50  eval('class ' . $realClassName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {
51  public function validate($value){} public function getOptions(){}
52  }');
53  $this->assertEquals($realClassName, $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName));
54  }
55 
60  {
61  $className = $this->getUniqueId('Foo');
62  $validatorName = 'tx_foo:' . $className;
63  $this->setExpectedException(\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException::class, '', 1365799920);
64  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
65  }
66 
71  {
72  $extensionName = 'tx_foo';
73  $className = $this->getUniqueId('Foo');
74  $realClassName = 'Tx_' . $extensionName . '_Validation_Validator_' . $className . 'Validator';
75  $validatorName = $extensionName . ':' . $className;
76  eval('class ' . $realClassName . '{}');
77  $this->setExpectedException(\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException::class, '', 1365776838);
78  $this->validatorResolver->_call('resolveValidatorObjectName', $validatorName);
79  }
80 
81  /****************/
82 
87  {
88  $className = $this->getUniqueId('Foo_');
89  $expectedValidatorName = $className . 'Validator';
90  eval('class ' . $expectedValidatorName . ' implements TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface {
91  public function validate($value){} public function getOptions(){}
92  }');
93  $this->assertEquals(
94  $expectedValidatorName,
95  $this->validatorResolver->_call('resolveValidatorObjectName', $className)
96  );
97  }
98 
103  {
104  $className = $this->getUniqueId('Foo');
105  $this->setExpectedException(\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException::class, '', 1365799920);
106  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
107  }
108 
113  {
114  $className = $this->getUniqueId('Foo_');
115  $expectedValidatorName = $className . 'Validator';
116  eval('class ' . $expectedValidatorName . '{}');
117  $this->setExpectedException(\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException::class, '', 1365776838);
118  $this->validatorResolver->_call('resolveValidatorObjectName', $className);
119  }
120 
121  /****************/
122 
127  {
128  return [
129  ['TYPO3\\CMS\\Mypkg\\Validation\\Validator', 'MySecondValidator', 'TYPO3.CMS.Mypkg:MySecond'],
130  ['Acme\\Mypkg\\Validation\\Validator', 'MyThirdValidator', 'Acme.Mypkg:MyThird']
131  ];
132  }
133 
142  public function resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname)
143  {
144  eval('namespace ' . $namespace . '; class ' . $className . ' implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
145  public function validate($value){} public function getOptions(){}
146  }');
147  $this->assertSame($namespace . '\\' . $className, $this->validatorResolver->_call('resolveValidatorObjectName', $shorthandValidatorname));
148  }
149 
154  {
155  eval('namespace TYPO3\\CMS\\Extbase\\Validation\\Validator;' . LF . 'class FooValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
156  public function validate($value){} public function getOptions(){}
157  }');
158  $this->assertSame('TYPO3\\CMS\\Extbase\\Validation\\Validator\\FooValidator', $this->validatorResolver->_call('resolveValidatorObjectName', 'Foo'));
159  }
160 
164  public function createValidatorResolvesAndReturnsAValidatorAndPassesTheGivenOptions()
165  {
166  $className = $this->getUniqueId('Test');
167  $mockValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ObjectValidatorInterface::class, ['validate', 'getOptions', 'setValidatedInstancesContainer'], [], $className);
168  $this->mockObjectManager->expects($this->any())->method('get')->with($className)->will($this->returnValue($mockValidator));
170  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName']);
171  $validatorResolver->_set('objectManager', $this->mockObjectManager);
172  $validatorResolver->expects($this->once())->method('resolveValidatorObjectName')->with($className)->will($this->returnValue($className));
173  $validator = $validatorResolver->createValidator($className);
174  $this->assertSame($mockValidator, $validator);
175  }
176 
181  {
182  $this->markTestSkipped('');
183  $className = $this->getUniqueId('Test');
184  $this->setExpectedException(\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException::class, '', 1365799920);
185  $this->validatorResolver->createValidator($className);
186  }
187 
192  {
193  $this->markTestSkipped('Functionality is different now.');
194  $mockConjunctionValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class, [], [], '', false);
195  $validatorResolver = $this->getMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['buildBaseValidatorConjunction'], [], '', false);
196  $validatorResolver->expects($this->once())->method('buildBaseValidatorConjunction')->with('Tx_Virtual_Foo')->will($this->returnValue($mockConjunctionValidator));
197  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
198  $this->assertSame($mockConjunctionValidator, $result, '#1');
199  $result = $validatorResolver->getBaseValidatorConjunction('Tx_Virtual_Foo');
200  $this->assertSame($mockConjunctionValidator, $result, '#2');
201  }
202 
207  {
208  $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, ['fooAction'], [], '', false);
209  $methodParameters = [];
210  $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, [], [], '', false);
211  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
212  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
213  $validatorResolver->_set('reflectionService', $mockReflectionService);
214  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
215  $this->assertSame([], $result);
216  }
217 
222  {
223  $mockObject = $this->getMock('stdClass', ['fooMethod'], [], '', false);
224  $methodParameters = [
225  'arg1' => [
226  'type' => 'string'
227  ],
228  'arg2' => [
229  'type' => 'array'
230  ]
231  ];
232  $methodTagsValues = [
233  'param' => [
234  'string $arg1',
235  'array $arg2'
236  ],
237  'validate' => [
238  '$arg1 Foo(bar = baz), Bar',
239  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
240  ]
241  ];
242  $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, [], [], '', false);
243  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
244  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
245  $mockStringValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
246  $mockArrayValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
247  $mockFooValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
248  $mockBarValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
249  $mockQuuxValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
250  $conjunction1 = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class, [], [], '', false);
251  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
252  $conjunction1->expects($this->at(1))->method('addValidator')->with($mockFooValidator);
253  $conjunction1->expects($this->at(2))->method('addValidator')->with($mockBarValidator);
254  $conjunction2 = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class, [], [], '', false);
255  $conjunction2->expects($this->at(0))->method('addValidator')->with($mockArrayValidator);
256  $conjunction2->expects($this->at(1))->method('addValidator')->with($mockQuuxValidator);
257  $mockArguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
258  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg1', 'dummyValue'));
259  $mockArguments->addArgument(new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('arg2', 'dummyValue'));
260  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
261  $validatorResolver->expects($this->at(0))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction1));
262  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
263  $validatorResolver->expects($this->at(2))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction2));
264  $validatorResolver->expects($this->at(3))->method('createValidator')->with('array')->will($this->returnValue($mockArrayValidator));
265  $validatorResolver->expects($this->at(4))->method('createValidator')->with('Foo', ['bar' => 'baz'])->will($this->returnValue($mockFooValidator));
266  $validatorResolver->expects($this->at(5))->method('createValidator')->with('Bar')->will($this->returnValue($mockBarValidator));
267  $validatorResolver->expects($this->at(6))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
268  $validatorResolver->_set('reflectionService', $mockReflectionService);
269  $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
270  $this->assertEquals(['arg1' => $conjunction1, 'arg2' => $conjunction2], $result);
271  }
272 
278  {
279  $mockObject = $this->getMock('stdClass', ['fooMethod'], [], '', false);
280  $methodParameters = [
281  'arg1' => [
282  'type' => 'string'
283  ]
284  ];
285  $methodTagsValues = [
286  'param' => [
287  'string $arg1'
288  ],
289  'validate' => [
290  '$arg2 VENDOR\\ModelCollection\\Domain\\Model\\Model'
291  ]
292  ];
293  $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, [], [], '', false);
294  $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodTagsValues));
295  $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockObject), 'fooAction')->will($this->returnValue($methodParameters));
296  $mockStringValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
297  $mockQuuxValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class, [], [], '', false);
298  $conjunction1 = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class, [], [], '', false);
299  $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
300  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['createValidator']);
301  $validatorResolver->expects($this->at(0))->method('createValidator')->with(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class)->will($this->returnValue($conjunction1));
302  $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
303  $validatorResolver->expects($this->at(2))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Model\\Model')->will($this->returnValue($mockQuuxValidator));
304  $validatorResolver->_set('reflectionService', $mockReflectionService);
305  $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockObject), 'fooAction');
306  }
307 
312  {
313  $mockObject = $this->getMock('stdClass');
314  $className = get_class($mockObject);
315  $propertyTagsValues = [
316  'foo' => [
317  'var' => ['string'],
318  'validate' => [
319  'Foo(bar= baz), Bar',
320  'Baz'
321  ]
322  ],
323  'bar' => [
324  'var' => ['integer'],
325  'validate' => [
326  'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'
327  ]
328  ]
329  ];
330 
331  $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, [], [], '', false);
332  $mockReflectionService->expects($this->at(0))->method('getClassPropertyNames')->with($className)->will($this->returnValue(['foo', 'bar']));
333  $mockReflectionService->expects($this->at(1))->method('getPropertyTagsValues')->with($className, 'foo')->will($this->returnValue($propertyTagsValues['foo']));
334  $mockReflectionService->expects($this->at(2))->method('getPropertyTagsValues')->with($className, 'bar')->will($this->returnValue($propertyTagsValues['bar']));
335  $mockObjectValidator = $this->getMock(\TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator::class, ['dummy'], [], '', false);
336  $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, [], [], '', false);
337  $mockObjectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator::class)->will($this->returnValue($mockObjectValidator));
338  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName', 'createValidator']);
339  $validatorResolver->_set('reflectionService', $mockReflectionService);
340  $validatorResolver->_set('objectManager', $mockObjectManager);
341  $validatorResolver->expects($this->at(0))->method('createValidator')->with('Foo', ['bar' => 'baz'])->will($this->returnValue($mockObjectValidator));
342  $validatorResolver->expects($this->at(1))->method('createValidator')->with('Bar')->will($this->returnValue($mockObjectValidator));
343  $validatorResolver->expects($this->at(2))->method('createValidator')->with('Baz')->will($this->returnValue($mockObjectValidator));
344  $validatorResolver->expects($this->at(3))->method('createValidator')->with('VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator')->will($this->returnValue($mockObjectValidator));
345  $validatorResolver->_call('buildBaseValidatorConjunction', $className, $className);
346  }
347 
353  public function modelNamesProvider()
354  {
355  return [
356  'no replace' => ['VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'],
357  'replace in not namespaced class' => ['Tx_ModelCollection_Domain_Model_Model', 'Tx_ModelCollection_Domain_Validator_ModelValidator'],
358  'replace in namespaced class' => ['VENDOR\\ModelCollection\\Domain\\Model\\Model', 'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator']
359  ];
360  }
361 
369  public function buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName)
370  {
371  $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, [], [], '', false);
372  $validatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['resolveValidatorObjectName', 'createValidator']);
373  $validatorResolver->_set('objectManager', $mockObjectManager);
374  $validatorResolver->expects($this->once())->method('createValidator')->with($validatorClassName)->will($this->returnValue(null));
375  $validatorResolver->_call('buildBaseValidatorConjunction', $modelClassName, $modelClassName);
376  }
377 
382  {
383  $validatorName = $this->getUniqueId('FooValidator');
384  eval('namespace TYPO3\CMS\Extbase\Validation\Validator;' . LF . 'class ' . $validatorName . 'Validator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
385  public function validate($value){} public function getOptions(){}
386  }');
387  $mockValidatorResolver = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\ValidatorResolver::class, ['getValidatorType']);
388  $mockValidatorResolver->expects($this->once())->method('getValidatorType')->with($validatorName)->will($this->returnValue($validatorName));
389 
390  $mockValidatorResolver->_call('resolveValidatorObjectName', $validatorName);
391  }
392 
397  {
398  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'integer'));
399  $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'int'));
400  $this->assertEquals('String', $this->validatorResolver->_call('getValidatorType', 'string'));
401  $this->assertEquals('Array', $this->validatorResolver->_call('getValidatorType', 'array'));
402  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'float'));
403  $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'double'));
404  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'boolean'));
405  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
406  $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool'));
407  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'number'));
408  $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'numeric'));
409  }
410 
415  {
416  $this->assertEquals('Raw', $this->validatorResolver->_call('getValidatorType', 'mixed'));
417  }
418 
423  public function validatorAnnotations()
424  {
425  return [
426  [
427  '$var Bar',
428  [
429  'argumentName' => 'var',
430  'validators' => [
431  ['validatorName' => 'Bar', 'validatorOptions' => []]
432  ]
433  ]
434  ],
435  [
436  '$var Bar, Foo',
437  [
438  'argumentName' => 'var',
439  'validators' => [
440  ['validatorName' => 'Bar', 'validatorOptions' => []],
441  ['validatorName' => 'Foo', 'validatorOptions' => []]
442  ]
443  ]
444  ],
445  [
446  '$var Baz (Foo=Bar)',
447  [
448  'argumentName' => 'var',
449  'validators' => [
450  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => 'Bar']]
451  ]
452  ]
453  ],
454  [
455  '$var Buzz (Foo="B=a, r", Baz=1)',
456  [
457  'argumentName' => 'var',
458  'validators' => [
459  ['validatorName' => 'Buzz', 'validatorOptions' => ['Foo' => 'B=a, r', 'Baz' => '1']]
460  ]
461  ]
462  ],
463  [
464  '$var Foo(Baz=1, Bar=Quux)',
465  [
466  'argumentName' => 'var',
467  'validators' => [
468  ['validatorName' => 'Foo', 'validatorOptions' => ['Baz' => '1', 'Bar' => 'Quux']]
469  ]
470  ]
471  ],
472  [
473  '$var Pax, Foo(Baz = \'1\', Bar = Quux)',
474  [
475  'argumentName' => 'var',
476  'validators' => [
477  ['validatorName' => 'Pax', 'validatorOptions' => []],
478  ['validatorName' => 'Foo', 'validatorOptions' => ['Baz' => '1', 'Bar' => 'Quux']]
479  ]
480  ]
481  ],
482  [
483  '$var Reg (P="[at]*(h|g)"), Quux',
484  [
485  'argumentName' => 'var',
486  'validators' => [
487  ['validatorName' => 'Reg', 'validatorOptions' => ['P' => '[at]*(h|g)']],
488  ['validatorName' => 'Quux', 'validatorOptions' => []]
489  ]
490  ]
491  ],
492  [
493  '$var Baz (Foo="B\\"ar")',
494  [
495  'argumentName' => 'var',
496  'validators' => [
497  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => 'B"ar']]
498  ]
499  ]
500  ],
501  [
502  '$var F3_TestPackage_Quux',
503  [
504  'argumentName' => 'var',
505  'validators' => [
506  ['validatorName' => 'F3_TestPackage_Quux', 'validatorOptions' => []]
507  ]
508  ]
509  ],
510  [
511  '$var Baz(Foo="5"), Bar(Quux="123")',
512  [
513  'argumentName' => 'var',
514  'validators' => [
515  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => '5']],
516  ['validatorName' => 'Bar', 'validatorOptions' => ['Quux' => '123']]
517  ]
518  ]
519  ],
520  [
521  '$var Baz(Foo="2"), Bar(Quux=123, Pax="a weird \\"string\\" with *freaky* \\stuff")',
522  [
523  'argumentName' => 'var',
524  'validators' => [
525  ['validatorName' => 'Baz', 'validatorOptions' => ['Foo' => '2']],
526  ['validatorName' => 'Bar', 'validatorOptions' => ['Quux' => '123', 'Pax' => 'a weird "string" with *freaky* \\stuff']]
527  ]
528  ]
529  ],
530  'namespaced validator class name' => [
531  'annotation' => '$var F3\TestPackage\Quux',
532  'expected' => [
533  'argumentName' => 'var',
534  'validators' => [
535  ['validatorName' => 'F3\TestPackage\Quux', 'validatorOptions' => []]
536  ]
537  ]
538  ],
539  'shorthand notation for system validator' => [
540  'annotation' => '$var TYPO3.CMS.Mypkg:MySecond',
541  'expected' => [
542  'argumentName' => 'var',
543  'validators' => [
544  ['validatorName' => 'TYPO3.CMS.Mypkg:MySecond', 'validatorOptions' => []]
545  ]
546  ]
547  ],
548  'shorthand notation for custom validator with parameter' => [
549  'annotation' => '$var Acme.Mypkg:MyThird(Foo="2")',
550  'expected' => [
551  'argumentName' => 'var',
552  'validators' => [
553  ['validatorName' => 'Acme.Mypkg:MyThird', 'validatorOptions' => ['Foo' => '2']]
554  ]
555  ]
556  ],
557  ];
558  }
559 
566  public function parseValidatorAnnotationCanParseAnnotations($annotation, $expectedResult)
567  {
568  $result = $this->validatorResolver->_call('parseValidatorAnnotation', $annotation);
569  $this->assertEquals($result, $expectedResult);
570  }
571 }
buildBaseValidatorConjunctionCreatesValidatorFromClassName($modelClassName, $validatorClassName)
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
resolveValidatorObjectNameCanResolveNamespacedShorthandValidatornames($namespace, $className, $shorthandValidatorname)