Skip to content

Commit

Permalink
Merge pull request #7 from gabriel-caruso/phpunit-6
Browse files Browse the repository at this point in the history
Support PHPUnit 6 and PHPUnit Mock Objects 4
  • Loading branch information
mnapoli authored Nov 11, 2017
2 parents 8bb8290 + 61de566 commit 5335193
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
26 changes: 16 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
language: php

sudo: false

notifications:
email:
on_success: never

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- nightly

matrix:
fast_finish: true
allow_failures:
- php: nightly
include:
- php: 5.4
- php: 7.0
env: dependencies=lowest

before_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then composer require satooshi/php-coveralls:dev-master -n ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then composer install -n ; fi
- if [[ $(phpenv version-name) == '7.1' ]]; then composer require satooshi/php-coveralls:dev-master -n ; fi
- if [[ $(phpenv version-name) != '7.1' ]]; then composer install -n ; fi
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;

script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then vendor/bin/phpunit ; fi
- if [[ $(phpenv version-name) == '7.1' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $(phpenv version-name) != '7.1' ]]; then vendor/bin/phpunit ; fi

after_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then php vendor/bin/coveralls -v ; fi
- if [[ $(phpenv version-name) == '7.1' ]]; then php vendor/bin/coveralls -v ; fi
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
}
},
"require": {
"php": "~5.4|~7.0",
"phpunit/phpunit-mock-objects": "~2.0|~3.0"
"php": "~7.0",
"phpunit/phpunit-mock-objects": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpunit": "~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('PHPUnit\Framework\TestCase', '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 5335193

Please sign in to comment.