-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Description
Symfony allows to compose constraints out of constraints using the Compound
base class. This is a great tool for cases where a custom validator would be overkill. However, I think we're lacking a nice way to test these compounds. The documentation of compounds does not explain how to test them either.
There is a ConstraintValidatorTestCase
class that can be used for custom validators, but that class does not work on compounds because it creates a fully mocked validator that would not delegate the validation to the proper validators for the constraints that the compound is composed of.
Currently, I'm running a functional test (using KernelTestCase
) to test compounds but that boots the whole kernel (which feels unnecessary) and lacks the tooling that ConstraintValidatorTestCase
provides to assert expected violations.
It would be nice to have a CompoundConstraintTestCase
that works like ConstraintValidatorTestCase
but would allow the delegating calls to the individual validators.
Example
No response