[BUGFIX] Harden ValidatorResolver and add functional tests 75/55275/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Fri, 5 Jan 2018 11:21:52 +0000 (12:21 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 13 Jan 2018 12:36:01 +0000 (13:36 +0100)
commitb3c4c42384fe9affde9b36e767e543ef2c90bf1a
tree4415e123b8729e0ecdf0b82aa5b23608950f9cb9
parent91bc637a269506acbae17dd4e72ae1c319746500
[BUGFIX] Harden ValidatorResolver and add functional tests

This patch mainly converts several unit tests with heavy
mocking to functional tests with real fixtures instead of
'eval()'ed classes.

During that seperation two minor bugs have been fixed:

- "resolveValidatorObjectName" tried to find non FQCN
  validators by checking for a colon, an underscore or
  a backslash. That way it found shorthand validators
  like "TYPO3.CMS.Extbase:NotEmpty" and validators
  without any extension reference. e.g. "NotEmpty".

  While that check itself is not a problem, the resolver
  furthermore explodes the validator name by colons,
  which fails for validator names without extension
  reference. This has been fixed by an additional elseif.

- Another small bug has been fixed in the method
  "buildBaseValidatorConjunction".

  While aggregating the validator annotations, the
  method "parseValidatorAnnotation" is called that
  returns an array with the annotation information.
  If the information is built for a method param,
  the key argumentName is set. However, this is not
  the case for properties but following code relied
  on argumentName being present. argumentName is
  now explicitly set to null if not given.

Releases: master
Resolves: #83481
Change-Id: I413b85ad905c19f6ae7daef8f5d97aeeab2edb90
Reviewed-on: https://review.typo3.org/55275
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Controller/TestController.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Domain/Model/AnotherModel.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Domain/Model/Model.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Domain/Validator/ModelValidator.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Validation/Validator/CustomValidator.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/Fixture/Validation/Validator/CustomValidatorThatDoesNotImplementValidatorInterfaceValidator.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Validation/ValidatorResolverTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php