Symfony2 LiipFunctionalTestBundle overriding @validator service

283 Views Asked by At

I am trying to inject @validator into my service but LiipFunctionalTestBundle is overriding that service when it gets injected.

admin.image_service:
    class: AdminBundle\Service\ImageService
    arguments: ["@validator", "@doctrine.orm.admin_entity_manager", "@image_storage_filesystem"]

Which results in the error

must be an instance of Symfony\Component\Validator\Validator\RecursiveValidator, instance of Liip\FunctionalTestBundle\Validator\DataCollectingValidator given

running php bin/console debug:container results in

liip_functional_test.validator: Liip\FunctionalTestBundle\Validator\DataCollectingValidator

validator: alias for "liip_functional_test.validator"

Is there a way to get around this over than remove liip and refactor all of my tests?

1

There are 1 best solutions below

1
On BEST ANSWER

In Your service you should typehint Interface not exact class.

Instdead Symfony\Component\Validator\Validator\RecursiveValidator use Symfony\Component\Validator\Validator\ValidatorInterface - which is implemented by both classes (Symfony and Liip).