Created
July 31, 2018 09:53
-
-
Save blackandred/be5ab9c96aa7a75b9b8c60e30dae0f46 to your computer and use it in GitHub Desktop.
Symfony: Mock Symfony validator to return always true in isValid() for functional testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function mockFormValidationToReturnValid(): void | |
{ | |
$form = $this->createMock(FormInterface::class); | |
$form->method('isValid')->willReturn(true); | |
$factory = $this->createMock(FormFactoryInterface::class); | |
$factory->method('create')->willReturn(FormInterface::class)->willReturn($form); | |
$this->getContainer()->set('form.factory', $factory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment