Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for PHPUnit 6.5 and 7.0
- Loading branch information
1 parent
b42fc41
commit 15f769a
Showing
10 changed files
with
155 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
if (! interface_exists(\PHPUnit\Framework\MockObject\Matcher\Invocation::class)) { | ||
class_alias( | ||
\PHPUnit_Framework_MockObject_Matcher_Invocation::class, | ||
\PHPUnit\Framework\MockObject\Matcher\Invocation::class | ||
); | ||
} | ||
|
||
if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)) { | ||
class_alias( | ||
\PHPUnit_Framework_MockObject_Invocation::class, | ||
\PHPUnit\Framework\MockObject\Invocation::class | ||
); | ||
} | ||
|
||
if (! interface_exists(\PHPUnit\Framework\MockObject\MockObject::class)) { | ||
class_alias( | ||
\PHPUnit_Framework_MockObject_MockObject::class, | ||
\PHPUnit\Framework\MockObject\MockObject::class | ||
); | ||
} | ||
|
||
if (! class_exists(\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class)) { | ||
class_alias( | ||
\PHPUnit_Framework_MockObject_Builder_InvocationMocker::class, | ||
\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class | ||
); | ||
} | ||
|
||
if (! class_exists(\PHPUnit\Framework\BaseTestListener::class)) { | ||
include __DIR__ . '/compatibility/BaseTestListener.php'; | ||
class_alias( | ||
phpmock\phpunit\MockDisablerPHPUnit7::class, | ||
phpmock\phpunit\MockDisabler::class | ||
); | ||
} else { | ||
class_alias( | ||
phpmock\phpunit\MockDisablerPHPUnit6::class, | ||
phpmock\phpunit\MockDisabler::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
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,51 @@ | ||
<?php | ||
|
||
namespace phpmock\phpunit; | ||
|
||
use phpmock\Deactivatable; | ||
use PHPUnit\Framework\BaseTestListener; | ||
use PHPUnit\Framework\Test; | ||
|
||
/** | ||
* Test listener for PHPUnit integration. | ||
* | ||
* This class disables mock functions after a test was run. | ||
* | ||
* @author Markus Malkusch <markus@malkusch.de> | ||
* @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations | ||
* @license http://www.wtfpl.net/txt/copying/ WTFPL | ||
* @internal | ||
*/ | ||
class MockDisablerPHPUnit7 extends BaseTestListener | ||
{ | ||
|
||
/** | ||
* @var Deactivatable The function mocks. | ||
*/ | ||
private $deactivatable; | ||
|
||
/** | ||
* Sets the function mocks. | ||
* | ||
* @param Deactivatable $deactivatable The function mocks. | ||
*/ | ||
public function __construct(Deactivatable $deactivatable) | ||
{ | ||
$this->deactivatable = $deactivatable; | ||
} | ||
|
||
/** | ||
* Disables the function mocks. | ||
* | ||
* @param Test $test The test. | ||
* @param int $time The test duration. | ||
* | ||
* @see Mock::disable() | ||
*/ | ||
public function endTest(Test $test, float $time) : void | ||
{ | ||
parent::endTest($test, $time); | ||
|
||
$this->deactivatable->disable(); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace PHPUnit\Framework; | ||
|
||
/** | ||
* Compatibility class to work with PHPUnit 7 | ||
* | ||
* @internal | ||
*/ | ||
abstract class BaseTestListener implements TestListener | ||
{ | ||
use TestListenerDefaultImplementation; | ||
} |
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