-
-
Notifications
You must be signed in to change notification settings - Fork 19
Fixes PHPUnit 8.4 compatibility #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.phpunit.result.cache | ||
vendor/ | ||
composer.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace phpmock\phpunit; | ||
|
||
use phpmock\generator\MockFunctionGenerator; | ||
use PHPUnit\Framework\MockObject\Invocation; | ||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder; | ||
|
||
/** | ||
* Removes default arguments from the invocation. | ||
* | ||
* @author Markus Malkusch <[email protected]> | ||
* @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations | ||
* @license http://www.wtfpl.net/txt/copying/ WTFPL | ||
* @internal | ||
*/ | ||
class DefaultArgumentRemoverReturnTypes84 extends InvocationOrder | ||
{ | ||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
public function invokedDo(Invocation $invocation) | ||
{ | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
public function matches(Invocation $invocation) : bool | ||
{ | ||
$iClass = class_exists(Invocation::class); | ||
|
||
if ($invocation instanceof Invocation\StaticInvocation | ||
|| $iClass | ||
) { | ||
$this->removeDefaultArguments( | ||
$invocation, | ||
$iClass ? Invocation::class : Invocation\StaticInvocation::class | ||
); | ||
} else { | ||
MockFunctionGenerator::removeDefaultArguments($invocation->parameters); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public function verify() : void | ||
{ | ||
} | ||
|
||
/** | ||
* This method is not defined in the interface, but used in | ||
* PHPUnit_Framework_MockObject_InvocationMocker::hasMatchers(). | ||
* | ||
* @return boolean | ||
* @see \PHPUnit_Framework_MockObject_InvocationMocker::hasMatchers() | ||
*/ | ||
public function hasMatchers() | ||
{ | ||
return false; | ||
} | ||
|
||
public function toString() : string | ||
{ | ||
return __CLASS__; | ||
} | ||
|
||
/** | ||
* Remove default arguments from StaticInvocation or its children (hack) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
private function removeDefaultArguments(Invocation $invocation, string $class) | ||
{ | ||
$remover = function () { | ||
MockFunctionGenerator::removeDefaultArguments($this->parameters); | ||
}; | ||
|
||
$remover->bindTo($invocation, $class)(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace phpmock\phpunit; | ||
|
||
use PHPUnit\Framework\MockObject\Builder\InvocationMocker as BuilderInvocationMocker; | ||
use PHPUnit\Framework\MockObject\InvocationHandler; | ||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use phpmock\integration\MockDelegateFunctionBuilder; | ||
|
||
/** | ||
* Proxy for PHPUnit's PHPUnit_Framework_MockObject_MockObject. | ||
* | ||
* @author Markus Malkusch <[email protected]> | ||
* @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations | ||
* @license http://www.wtfpl.net/txt/copying/ WTFPL | ||
* @internal | ||
*/ | ||
class MockObjectProxyReturnTypes84 implements MockObject | ||
{ | ||
|
||
/** | ||
* @var MockObject $mockObject The mock object. | ||
*/ | ||
private $mockObject; | ||
|
||
/** | ||
* Inject the subject. | ||
* | ||
* @param MockObject $mockObject The subject. | ||
*/ | ||
public function __construct(MockObject $mockObject) | ||
{ | ||
$this->mockObject = $mockObject; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
// @codingStandardsIgnoreStart | ||
public function __phpunit_getInvocationHandler(): InvocationHandler | ||
{ | ||
return $this->mockObject->__phpunit_getInvocationHandler(); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
// @codingStandardsIgnoreStart | ||
public function __phpunit_setOriginalObject($originalObject) : void | ||
{ | ||
// @codingStandardsIgnoreEnd | ||
$this->mockObject->__phpunit_setOriginalObject($originalObject); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
// @codingStandardsIgnoreStart | ||
public function __phpunit_verify(bool $unsetInvocationMocker = true) : void | ||
{ | ||
// @codingStandardsIgnoreEnd | ||
$this->mockObject->__phpunit_verify($unsetInvocationMocker); | ||
} | ||
|
||
public function expects(InvocationOrder $matcher) : BuilderInvocationMocker | ||
{ | ||
return $this->mockObject->expects($matcher)->method(MockDelegateFunctionBuilder::METHOD); | ||
} | ||
|
||
/** | ||
* This method is not part of the contract but was found in | ||
* PHPUnit's mocked_class.tpl.dist. | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
// @codingStandardsIgnoreStart | ||
public function __phpunit_hasMatchers() : bool | ||
{ | ||
// @codingStandardsIgnoreEnd | ||
return $this->mockObject->__phpunit_hasMatchers(); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
// @codingStandardsIgnoreStart | ||
public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration) : void | ||
{ | ||
// @codingStandardsIgnoreEnd | ||
$this->mockObject->__phpunit_setReturnValueGeneration($returnValueGeneration); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.