Skip to content

Commit

Permalink
Support PHPUnit 6 and PHPUnit Mock Objects 4
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed Nov 11, 2017
1 parent 8bb8290 commit 754810d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ composer require --dev mnapoli/phpunit-easymock
To be able to use EasyMock in your tests **you must include the trait in your class**:

```php
class MyTest extends \PHPUnit_Framework_TestCase
class MyTest extends \PHPUnit\Framework\TestCase
{
use \EasyMock\EasyMock;

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"require": {
"php": "~5.4|~7.0",
"phpunit/phpunit-mock-objects": "~2.0|~3.0"
"phpunit/phpunit-mock-objects": "~2.0|~3.0|~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpunit": "~4.8.35|~5.7|~6.4"
}
}
8 changes: 5 additions & 3 deletions tests/EasyMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
use EasyMock\Test\Fixture\ClassWithConstructor;
use EasyMock\Test\Fixture\CustomException;
use EasyMock\Test\Fixture\InterfaceFixture;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class EasyMockTest extends \PHPUnit_Framework_TestCase
class EasyMockTest extends TestCase
{
use EasyMock;

Expand Down Expand Up @@ -126,7 +128,7 @@ public function should_allow_to_spy_method_calls()
));

// Test PHPUnit's internals to check that the spy was registered
$property = new \ReflectionProperty('PHPUnit_Framework_TestCase', 'mockObjects');
$property = new \ReflectionProperty(TestCase::class, 'mockObjects');
$property->setAccessible(true);
$mockObjects = $property->getValue($this);

Expand All @@ -137,7 +139,7 @@ public function should_allow_to_spy_method_calls()
try {
$mock->__phpunit_verify();
$this->fail('Exception not thrown');
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
$this->assertContains('Expected invocation at least once but it never occur', $e->getMessage());
}

Expand Down

0 comments on commit 754810d

Please sign in to comment.