Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 LiipFunctionalTestBundle overriding @validator service

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?

like image 605
danwoodbury Avatar asked Mar 08 '16 19:03

danwoodbury


1 Answers

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).

like image 68
Paweł Mikołajczuk Avatar answered Nov 15 '22 00:11

Paweł Mikołajczuk