Skip to content

Commit 6e5789a

Browse files
committed
Merge pull request #1017 from xabbuh/fix-recursive-validator-mocks
mock interfaces instead of their implementations
2 parents 86ddd27 + 51bc16c commit 6e5789a

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Tests/Request/RequestBodyParamConverterTest.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,15 @@ public function testApplyWithValidationErrors()
210210
$expectedPost = new Post('Post 1', 'This is a blog post');
211211
$validationErrors = $this->getMock('Symfony\Component\Validator\ConstraintViolationList');
212212

213-
if (class_exists('Symfony\Component\Validator\Validator\RecursiveValidator')) {
214-
$validator = $this
215-
->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator')
216-
->disableOriginalConstructor()
217-
->getMock();
213+
if (interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) {
214+
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
218215
$validator
219216
->expects($this->once())
220217
->method('validate')
221218
->with($expectedPost, null, array('group1'))
222219
->will($this->returnValue($validationErrors));
223220
} else {
224-
$validator = $this
225-
->getMockBuilder('Symfony\Component\Validator\Validator')
226-
->disableOriginalConstructor()
227-
->getMock();
221+
$validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
228222
$validator
229223
->expects($this->once())
230224
->method('validate')
@@ -320,15 +314,10 @@ public function testValidatorOptionsStructureAfterMergeWithUserOptions()
320314
);
321315
$config = $this->createConfiguration(null, null, $userOptions);
322316

323-
if (class_exists('Symfony\Component\Validator\Validator\RecursiveValidator')) {
324-
$validator = $this
325-
->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator')
326-
->disableOriginalConstructor()
327-
->getMock();
317+
if (interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) {
318+
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
328319
} else {
329-
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator')
330-
->disableOriginalConstructor()
331-
->getMock();
320+
$validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
332321
}
333322

334323
$this->converter = new RequestBodyParamConverter($this->serializer, null, null, $validator, 'validationErrors');

0 commit comments

Comments
 (0)