Skip to content

Commit cd71d4d

Browse files
authored
Merge pull request #10 from mimmi20/master
Allow PHPUnit 7.x and PHP 7.3
2 parents 39391e2 + 06763a6 commit cd71d4d

File tree

6 files changed

+68
-30
lines changed

6 files changed

+68
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.idea/
12
/vendor/
23
/composer.phar
34
/composer.lock

.travis.yml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,40 @@ php:
1010
- 7.0
1111
- 7.1
1212
- 7.2
13+
- 7.3
1314
- nightly
1415

15-
matrix:
16-
fast_finish: true
17-
allow_failures:
18-
- php: nightly
19-
include:
20-
- php: 7.0
21-
env: dependencies=lowest
16+
env:
17+
- COMPOSER_FLAGS="--prefer-lowest"
18+
- COMPOSER_FLAGS=""
19+
20+
stages:
21+
- test
22+
- test with coverage
2223

2324
cache:
2425
directories:
2526
- $HOME/.composer/cache
2627

27-
before_script:
28-
- composer install -n
29-
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
28+
before_install:
29+
- phpenv config-rm xdebug.ini || echo "xdebug not available"
30+
- composer self-update
31+
32+
install: travis_retry composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction --no-suggest $COMPOSER_FLAGS -vv
33+
34+
script: vendor/bin/phpunit --colors --columns 117 --no-coverage
35+
36+
jobs:
37+
allow_failures:
38+
- php: 7.3
39+
- php: nightly
40+
include:
41+
- php: nightly
42+
env: COMPOSER_FLAGS="--ignore-platform-reqs"
3043

31-
script:
32-
- vendor/bin/phpunit
44+
- stage: test with coverage
45+
os: linux
46+
php: 7.1
47+
env: COMPOSER_FLAGS=""
48+
before_install: composer self-update
49+
script: vendor/bin/phpunit --colors --coverage-text

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
},
1818
"require": {
1919
"php": "~7.0",
20-
"phpunit/phpunit-mock-objects": "~4.0"
20+
"phpunit/phpunit-mock-objects": "~5.0|~6.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "~6.4"
23+
"phpunit/phpunit": "~6.4|~7.0"
2424
}
2525
}

phpunit.xml.dist

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit colors="true"
3-
convertErrorsToExceptions="true"
4-
convertNoticesToExceptions="true"
5-
convertWarningsToExceptions="true"
6-
bootstrap="./vendor/autoload.php">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
beStrictAboutChangesToGlobalState="true"
8+
beStrictAboutCoversAnnotation="false"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTestsThatDoNotTestAnything="true"
11+
beStrictAboutTodoAnnotatedTests="true"
12+
failOnWarning="true"
13+
failOnRisky="true"
14+
verbose="false"
15+
bootstrap="vendor/autoload.php"
16+
enforceTimeLimit="false"
17+
colors="true"
18+
convertErrorsToExceptions="true"
19+
convertNoticesToExceptions="true"
20+
convertWarningsToExceptions="true"
21+
>
22+
<php>
23+
<ini name="error_reporting" value="-1"/>
24+
<ini name="memory_limit" value="-1"/>
25+
<ini name="date.timezone" value="UTC"/>
26+
</php>
727

828
<testsuites>
929
<testsuite name="Test suite">

src/EasyMock.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace EasyMock;
44

5-
use PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount as AnyInvokedCount;
6-
use PHPUnit_Framework_MockObject_Matcher_Invocation as InvocationMatcher;
7-
use PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce as InvokedAtLeastOnce;
8-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
5+
use PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
6+
use PHPUnit\Framework\MockObject\Matcher\Invocation as InvocationMatcher;
7+
use PHPUnit\Framework\MockObject\Matcher\InvokedAtLeastOnce;
8+
use PHPUnit\Framework\MockObject\MockObject;
99

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

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

4040
return $mock;
@@ -51,7 +51,7 @@ protected function easyMock($classname, array $methods = array())
5151
* @param string $classname The class to mock. Can also be an existing mock to mock new methods.
5252
* @param array $methods Array of values to return, indexed by the method name.
5353
*
54-
* @return \PHPUnit_Framework_MockObject_MockObject
54+
* @return \PHPUnit\Framework\MockObject\MockObject
5555
*/
5656
protected function easySpy($classname, array $methods = array())
5757
{

tests/EasyMockTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function should_mock_objects()
2525
/** @var ClassFixture $mock */
2626
$mock = $this->easyMock('EasyMock\Test\Fixture\ClassFixture');
2727

28-
$this->assertInstanceOf('PHPUnit_Framework_MockObject_MockObject', $mock);
28+
$this->assertInstanceOf('PHPUnit\Framework\MockObject\MockObject', $mock);
2929
$this->assertNull($mock->foo());
3030
}
3131

@@ -35,7 +35,7 @@ public function should_mock_objects()
3535
public function should_skip_the_constructor()
3636
{
3737
/** @var ClassWithConstructor $mock */
38-
$mock = $this->easyMock('EasyMock\Test\Fixture\ClassWithConstructor');
38+
$mock = $this->easyMock('\EasyMock\Test\Fixture\ClassWithConstructor');
3939
$this->assertFalse($mock->constructorCalled);
4040
}
4141

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

50-
$this->assertInstanceOf('PHPUnit_Framework_MockObject_MockObject', $mock);
50+
$this->assertInstanceOf('PHPUnit\Framework\MockObject\MockObject', $mock);
5151
$this->assertNull($mock->foo());
5252
}
5353

@@ -128,7 +128,7 @@ public function should_allow_to_spy_method_calls()
128128
));
129129

130130
// Test PHPUnit's internals to check that the spy was registered
131-
$property = new \ReflectionProperty('PHPUnit\Framework\TestCase', 'mockObjects');
131+
$property = new \ReflectionProperty('\PHPUnit\Framework\TestCase', 'mockObjects');
132132
$property->setAccessible(true);
133133
$mockObjects = $property->getValue($this);
134134

0 commit comments

Comments
 (0)