Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e53785b

Browse filesBrowse files
committed
bug #49220 [Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10 (gjuric)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #49218 | License | MIT As explained in #49218 `MockBuilder::setMethods()` has been removed from PHPUnit 10 and replaced with `MockBuilder::onlyMethods()`. This change checks if `onlyMethods()` is defined and if not falls back to old version that uses `setMethods()`. Commits ------- 7aa4fee [Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10
2 parents 9a11bbd + 7aa4fee commit e53785b
Copy full SHA for e53785b

File tree

Expand file treeCollapse file tree

1 file changed

+16
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-10
lines changed

‎src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
+16-10Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,22 @@ protected function createContext()
130130
$context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
131131
$context->setConstraint($this->constraint);
132132

133-
$contextualValidator = $this->getMockBuilder(AssertingContextualValidator::class)
134-
->setConstructorArgs([$context])
135-
->setMethods([
136-
'atPath',
137-
'validate',
138-
'validateProperty',
139-
'validatePropertyValue',
140-
'getViolations',
141-
])
142-
->getMock();
133+
$contextualValidatorMockBuilder = $this->getMockBuilder(AssertingContextualValidator::class)
134+
->setConstructorArgs([$context]);
135+
$contextualValidatorMethods = [
136+
'atPath',
137+
'validate',
138+
'validateProperty',
139+
'validatePropertyValue',
140+
'getViolations',
141+
];
142+
// PHPUnit 10 removed MockBuilder::setMethods()
143+
if (method_exists($contextualValidatorMockBuilder, 'onlyMethods')) {
144+
$contextualValidatorMockBuilder->onlyMethods($contextualValidatorMethods);
145+
} else {
146+
$contextualValidatorMockBuilder->setMethods($contextualValidatorMethods);
147+
}
148+
$contextualValidator = $contextualValidatorMockBuilder->getMock();
143149
$contextualValidator->expects($this->any())
144150
->method('atPath')
145151
->willReturnCallback(function ($path) use ($contextualValidator) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.