Skip to content

Commit e7762fd

Browse files
committed
Fix method names of Generator when using PHPUnit 10.4
1 parent 0216efe commit e7762fd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Stub.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,14 @@ private static function generateMockForAbstractClass(): object
433433
private static function doGenerateMock($args, $isAbstract = false)
434434
{
435435
$testCase = self::extractTestCaseFromArgs($args);
436-
$methodName = $isAbstract ? 'getMockForAbstractClass' : 'getMock';
436+
437+
// PHPUnit 10.4 changed method names
438+
if (version_compare(PHPUnitVersion::series(), '10.4', '>=')) {
439+
$methodName = $isAbstract ? 'mockObjectForAbstractClass' : 'testDouble';
440+
} else {
441+
$methodName = $isAbstract ? 'getMockForAbstractClass' : 'getMock';
442+
}
443+
437444
// PHPUnit 10.3 changed the namespace
438445
if (version_compare(PHPUnitVersion::series(), '10.3', '>=')) {
439446
$generatorClass = new Generator();

0 commit comments

Comments
 (0)