Skip to content

Commit

Permalink
Merge pull request #55 from frankdekker/Add-support-for-renamed-getMo…
Browse files Browse the repository at this point in the history
…ck-method

Add support for renamed get mock method
  • Loading branch information
frankdekker authored Oct 6, 2023
2 parents 64cc945 + 9476b14 commit 7e88587
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"scripts": {
"check": ["@check:phpstan", "@check:phpmd", "@check:phpcs"],
"check:phpstan": "phpstan analyse",
"check:phpmd": "phpmd src,tests text phpmd.xml.dist --suffixes=php --exclude /tests/*/data/*",
"check:phpmd": "phpmd src,tests text phpmd.xml.dist --suffixes php --exclude /tests/*/data/*",
"check:phpcs": "phpcs src tests",
"fix": "@fix:phpcbf",
"fix:phpcbf": "phpcbf src tests",
Expand Down
7 changes: 6 additions & 1 deletion src/Constraint/ValueProvider/Compound/InstanceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ public function getValues(): array
if (class_exists('PHPUnit\Framework\MockObject\Generator\Generator')) {
/** @var \PHPUnit\Framework\MockObject\Generator $mockGenerator */
$mockGenerator = new Generator();
if (method_exists($mockGenerator, 'testDouble')) {
$instance = $mockGenerator->testDouble($this->typehint, true, [], [], '', false);
} else {
$instance = $mockGenerator->getMock($this->typehint, [], [], '', false);
}
} else {
$mockGenerator = new \PHPUnit\Framework\MockObject\Generator();
$instance = $mockGenerator->getMock($this->typehint, [], [], '', false);
}
$instance = $mockGenerator->getMock($this->typehint, [], [], '', false);

return [$instance];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ public function getValues(): array
if (class_exists('PHPUnit\Framework\MockObject\Generator\Generator')) {
/** @var \PHPUnit\Framework\MockObject\Generator $mockGenerator */
$mockGenerator = new Generator();
if (method_exists($mockGenerator, 'mockObjectForAbstractClass')) {
$instance = $mockGenerator->mockObjectForAbstractClass($className, [], '', false, false);
} else {
$instance = $mockGenerator->getMockForAbstractClass($className, [], '', false, false);
}
} else {
$mockGenerator = new \PHPUnit\Framework\MockObject\Generator();
$instance = $mockGenerator->getMockForAbstractClass($className, [], '', false, false);
}
$instance = $mockGenerator->getMockForAbstractClass($className, [], '', false, false);

return [$instance];
}
Expand Down

0 comments on commit 7e88587

Please sign in to comment.