Skip to content

Commit 1f67e1a

Browse files
committed
Keep using addMethods() as fallback for older versions of PHPUnit
1 parent 6a35727 commit 1f67e1a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

classes/PHPMock.php

+5
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ public function getFunctionMock($namespace, $name)
6666
$delegateBuilder->build($name);
6767

6868
$builder = $this->getMockBuilder($delegateBuilder->getFullyQualifiedClassName());
69+
70+
// onlyMethods() and addMethods() were introduced in PHPUnit 8.3, addMethods() was deprecated in PHPUnit 11 and
71+
// removed in PHPUnit 12
6972
if (is_callable([$builder, 'onlyMethods'])) {
7073
$builder->onlyMethods(['delegate', $name]);
74+
} elseif (is_callable([$builder, 'addMethods'])) {
75+
$builder->addMethods([$name]);
7176
}
7277
$mock = $builder->getMock();
7378
$this->addMatcher($mock, $name);

0 commit comments

Comments
 (0)