I am trying to write a test for a model that has both some regular validators and a custom validator using the entity manager and query. I use phpunit for my tests if this is for some reason.
I am testing a custom validator in another test, drowning out both the entity manager and the request, and then checking some objects. Since this proves that custom validation works, I will only need to validate the normal validation, and if possible just leave the custom validator.
Here is my model:
abstract class BaseRequestModel { protected $clientId; protected $apiKey;
In my test, I get a validator, create an object and validate it.
$validator = ValidatorFactory::buildDefault()->getValidator(); $requestModel = new RequestModel(); $errors = $validator->validate($requestModel);
Of course, this fails because it cannot find the Validator defined for MyAssert \ Client, which is a service and needs to be resolved by some container for dependency injection.
Does anyone know how to block a custom validator or exclude it from the scan ?
source share