-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/phpunit-8.1-support'
- Loading branch information
Showing
7 changed files
with
208 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,75 @@ | ||
<?php | ||
|
||
namespace phpmock\phpunit; | ||
|
||
use phpmock\generator\MockFunctionGenerator; | ||
use PHPUnit\Framework\MockObject\Invocation; | ||
use PHPUnit\Framework\MockObject\Matcher\Invocation as InvocationInterface; | ||
|
||
/** | ||
* 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 DefaultArgumentRemoverReturnTypes implements InvocationInterface | ||
{ | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
public function invoked(Invocation $invocation) | ||
{ | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
public function matches(Invocation $invocation) : bool | ||
{ | ||
if ($invocation instanceof Invocation\StaticInvocation) { | ||
$this->removeDefaultArguments($invocation); | ||
} 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\StaticInvocation $invocation) | ||
{ | ||
$remover = function () { | ||
MockFunctionGenerator::removeDefaultArguments($this->parameters); | ||
}; | ||
|
||
$remover->bindTo($invocation, Invocation\StaticInvocation::class)(); | ||
} | ||
} |
This file contains 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 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,94 @@ | ||
<?php | ||
|
||
namespace phpmock\phpunit; | ||
|
||
use PHPUnit\Framework\MockObject\Builder\InvocationMocker as BuilderInvocationMocker; | ||
use PHPUnit\Framework\MockObject\InvocationMocker; | ||
use PHPUnit\Framework\MockObject\Matcher\Invocation; | ||
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 MockObjectProxyReturnTypes 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_getInvocationMocker() : InvocationMocker | ||
{ | ||
// @codingStandardsIgnoreEnd | ||
return $this->mockObject->__phpunit_getInvocationMocker(); | ||
} | ||
|
||
/** | ||
* @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(Invocation $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 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