-
-
Notifications
You must be signed in to change notification settings - Fork 20
Added support for PHPUnit 6.5 and 7.0 #27
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
michalbundyra
merged 1 commit into
php-mock:master
from
michalbundyra:feature/phpunit-6.5-and-7
Mar 23, 2018
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
42 changes: 42 additions & 0 deletions
autoload.php
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,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 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
51 changes: 51 additions & 0 deletions
classes/MockDisablerPHPUnit7.php
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,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 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
13 changes: 13 additions & 0 deletions
compatibility/BaseTestListener.php
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,13 @@ | ||
<?php | ||
|
||
namespace PHPUnit\Framework; | ||
|
||
/** | ||
* Compatibility class to work with PHPUnit 7 | ||
* | ||
* @internal | ||
*/ | ||
abstract class BaseTestListener implements TestListener | ||
{ | ||
use TestListenerDefaultImplementation; | ||
} |
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
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.