Category: mocking

How to mock a translator service to unit test a form component that depends on it?

In my Symfony app I use a form to send emails to the administrator: class ContactType extends AbstractType { private $translator; public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(‘name’, TextType::class,…