Skip to content

Commit 7841c01

Browse files
Add polyfill for TestCase::createMock()
1 parent b645f7b commit 7841c01

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Tests/DataCollector/ValidatorDataCollectorTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\DataCollector;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\ConstraintViolation;
1617
use Symfony\Component\Validator\ConstraintViolationList;
1718
use Symfony\Component\Validator\DataCollector\ValidatorDataCollector;
@@ -20,6 +21,8 @@
2021

2122
class ValidatorDataCollectorTest extends TestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
public function testCollectsValidatorCalls()
2427
{
2528
$originalValidator = $this->createMock(ValidatorInterface::class);
@@ -71,9 +74,4 @@ public function testReset()
7174
$this->assertCount(0, $collector->getCalls());
7275
$this->assertSame(0, $collector->getViolationsCount());
7376
}
74-
75-
protected function createMock($classname)
76-
{
77-
return $this->getMockBuilder($classname)->disableOriginalConstructor()->getMock();
78-
}
7977
}

Tests/Validator/TraceableValidatorTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\Validator;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\Constraint;
1617
use Symfony\Component\Validator\ConstraintViolation;
1718
use Symfony\Component\Validator\ConstraintViolationList;
@@ -23,6 +24,8 @@
2324

2425
class TraceableValidatorTest extends TestCase
2526
{
27+
use ForwardCompatTestTrait;
28+
2629
public function testValidate()
2730
{
2831
$originalValidator = $this->createMock(ValidatorInterface::class);
@@ -95,9 +98,4 @@ public function testForwardsToOriginalValidator()
9598
$expects('validatePropertyValue')->willReturn($expected = new ConstraintViolationList());
9699
$this->assertSame($expected, $validator->validatePropertyValue(new \stdClass(), 'property', 'value'), 'returns original validator validatePropertyValue() result');
97100
}
98-
99-
protected function createMock($classname)
100-
{
101-
return $this->getMockBuilder($classname)->disableOriginalConstructor()->getMock();
102-
}
103101
}

0 commit comments

Comments
 (0)