Skip to content

Allow PHPUnit 7.x and PHP 7.3 #10

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
merged 5 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
/vendor/
/composer.phar
/composer.lock
41 changes: 29 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,40 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

matrix:
fast_finish: true
allow_failures:
- php: nightly
include:
- php: 7.0
env: dependencies=lowest
env:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

stages:
- test
- test with coverage

cache:
directories:
- $HOME/.composer/cache

before_script:
- composer install -n
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- composer self-update

install: travis_retry composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction --no-suggest $COMPOSER_FLAGS -vv

script: vendor/bin/phpunit --colors --columns 117 --no-coverage

jobs:
allow_failures:
- php: 7.3
- php: nightly
include:
- php: nightly
env: COMPOSER_FLAGS="--ignore-platform-reqs"

script:
- vendor/bin/phpunit
- stage: test with coverage
os: linux
php: 7.1
env: COMPOSER_FLAGS=""
before_install: composer self-update
script: vendor/bin/phpunit --colors --coverage-text
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": "~7.0",
"phpunit/phpunit-mock-objects": "~4.0"
"phpunit/phpunit-mock-objects": "~5.0|~6.0"
},
"require-dev": {
"phpunit/phpunit": "~6.4"
"phpunit/phpunit": "~6.4|~7.0"
}
}
30 changes: 25 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
bootstrap="./vendor/autoload.php">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
failOnRisky="true"
verbose="false"
bootstrap="vendor/autoload.php"
enforceTimeLimit="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
<ini name="date.timezone" value="UTC"/>
</php>

<testsuites>
<testsuite name="Test suite">
Expand Down
14 changes: 7 additions & 7 deletions src/EasyMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace EasyMock;

use PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount as AnyInvokedCount;
use PHPUnit_Framework_MockObject_Matcher_Invocation as InvocationMatcher;
use PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce as InvokedAtLeastOnce;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
use PHPUnit\Framework\MockObject\Matcher\Invocation as InvocationMatcher;
use PHPUnit\Framework\MockObject\Matcher\InvokedAtLeastOnce;
use PHPUnit\Framework\MockObject\MockObject;

/**
* Generates mock objects.
Expand All @@ -23,7 +23,7 @@ trait EasyMock
* @param string $classname The class to mock. Can also be an existing mock to mock new methods.
* @param array $methods Array of values to return, indexed by the method name.
*
* @return \PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
protected function easyMock($classname, array $methods = array())
{
Expand All @@ -34,7 +34,7 @@ protected function easyMock($classname, array $methods = array())
}

foreach ($methods as $method => $return) {
$this->mockMethod($mock, $method, new AnyInvokedCount, $return);
$this->mockMethod($mock, $method, new AnyInvokedCount(), $return);
}

return $mock;
Expand All @@ -51,7 +51,7 @@ protected function easyMock($classname, array $methods = array())
* @param string $classname The class to mock. Can also be an existing mock to mock new methods.
* @param array $methods Array of values to return, indexed by the method name.
*
* @return \PHPUnit_Framework_MockObject_MockObject
* @return \PHPUnit\Framework\MockObject\MockObject
*/
protected function easySpy($classname, array $methods = array())
{
Expand Down
8 changes: 4 additions & 4 deletions tests/EasyMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function should_mock_objects()
/** @var ClassFixture $mock */
$mock = $this->easyMock('EasyMock\Test\Fixture\ClassFixture');

$this->assertInstanceOf('PHPUnit_Framework_MockObject_MockObject', $mock);
$this->assertInstanceOf('PHPUnit\Framework\MockObject\MockObject', $mock);
$this->assertNull($mock->foo());
}

Expand All @@ -35,7 +35,7 @@ public function should_mock_objects()
public function should_skip_the_constructor()
{
/** @var ClassWithConstructor $mock */
$mock = $this->easyMock('EasyMock\Test\Fixture\ClassWithConstructor');
$mock = $this->easyMock('\EasyMock\Test\Fixture\ClassWithConstructor');
$this->assertFalse($mock->constructorCalled);
}

Expand All @@ -47,7 +47,7 @@ public function should_mock_interfaces()
/** @var InterfaceFixture $mock */
$mock = $this->easyMock('EasyMock\Test\Fixture\InterfaceFixture');

$this->assertInstanceOf('PHPUnit_Framework_MockObject_MockObject', $mock);
$this->assertInstanceOf('PHPUnit\Framework\MockObject\MockObject', $mock);
$this->assertNull($mock->foo());
}

Expand Down Expand Up @@ -128,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 Down