Skip to content

Commit

Permalink
minor #21886 [Form] Add validate method to mockec validator in form T…
Browse files Browse the repository at this point in the history
…ypeTestCase (pierredup)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Add validate method to mockec validator in form TypeTestCase

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

When using the `Symfony\Component\Form\Tests\Extension\Validator\Type\TypeTestCase` class to unit test forms, the `validate` method is not mocked, which causes errors when the unit tests run.

Commits
-------

4013e7b Add validate method to mockec validator in form TypeTestCase
  • Loading branch information
nicolas-grekas committed Mar 6, 2017
2 parents 7311ef3 + 4013e7b commit 24f3135
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -23,6 +23,7 @@ protected function setUp()
$this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$this->validator->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata));
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(array()));

parent::setUp();
}
Expand Down

0 comments on commit 24f3135

Please sign in to comment.