5

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?

Community
  • 1
  • 1
danwoodbury
  • 311
  • 1
  • 11

1 Answers1

6

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

Paweł Mikołajczuk
  • 3,692
  • 25
  • 32