Skip to content

Commit b1fef62

Browse files
authored
Merge pull request #13 from b1rdex/phpunit-6
Add phpunit >=5.7 <7 compatibility
2 parents b8c13e9 + 003a0c6 commit b1fef62

File tree

4 files changed

+27
-44
lines changed

4 files changed

+27
-44
lines changed

.travis.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@ language: php
22

33
sudo: false
44

5-
php:
6-
- 5.6
7-
- 7.0
8-
- 7.1
9-
- nightly
10-
- hhvm
11-
12-
env:
13-
- PHPUNIT=4.7.*
14-
- PHPUNIT=4.8.*
15-
- PHPUNIT=5.0.*
16-
- PHPUNIT=5.1.*
17-
- PHPUNIT=5.2.*
18-
- PHPUNIT=5.3.*
19-
- PHPUNIT=5.4.*
20-
- PHPUNIT=5.5.*
21-
- PHPUNIT=5.6.*
22-
- PHPUNIT=5.7.*
23-
245
cache:
256
directories:
267
- $HOME/.composer
@@ -32,3 +13,17 @@ before_script:
3213

3314
script:
3415
- ./bin/phpunit
16+
17+
matrix:
18+
include:
19+
- php: 5.6
20+
env: PHPUNIT=~5.7
21+
- php: 7.0
22+
env: PHPUNIT=~5.7
23+
- php: 7.1
24+
env: PHPUNIT=~6
25+
- php: nightly
26+
env: PHPUNIT=~6
27+
- php: hhvm
28+
dist: trusty
29+
env: PHPUNIT=~5.7

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.6",
15-
"phpunit/phpunit": ">=4.7"
15+
"phpunit/phpunit": ">=5.7 <7"
1616
},
1717
"autoload": {
1818
"psr-4": { "MyBuilder\\PhpunitAccelerator\\": "src" }

src/TestListener.php

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

33
namespace MyBuilder\PhpunitAccelerator;
44

5-
class TestListener implements \PHPUnit_Framework_TestListener
5+
use PHPUnit\Framework\BaseTestListener;
6+
7+
if (!interface_exists('\PHPUnit\Framework\Test')) {
8+
class_alias('\PHPUnit_Framework_Test', '\PHPUnit\Framework\Test');
9+
}
10+
11+
class TestListener extends BaseTestListener
612
{
713
private $ignorePolicy;
814

@@ -13,7 +19,7 @@ public function __construct(IgnoreTestPolicy $ignorePolicy = null)
1319
$this->ignorePolicy = ($ignorePolicy) ?: new NeverIgnoreTestPolicy();
1420
}
1521

16-
public function endTest(\PHPUnit_Framework_Test $test, $time)
22+
public function endTest(\PHPUnit\Framework\Test $test, $time)
1723
{
1824
$testReflection = new \ReflectionObject($test);
1925

@@ -24,7 +30,7 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
2430
$this->safelyFreeProperties($test, $testReflection->getProperties());
2531
}
2632

27-
private function safelyFreeProperties(\PHPUnit_Framework_Test $test, array $properties)
33+
private function safelyFreeProperties(\PHPUnit\Framework\Test $test, array $properties)
2834
{
2935
foreach ($properties as $property) {
3036
if ($this->isSafeToFreeProperty($property)) {
@@ -43,29 +49,11 @@ private function isNotPhpUnitProperty(\ReflectionProperty $property)
4349
return 0 !== strpos($property->getDeclaringClass()->getName(), self::PHPUNIT_PROPERTY_PREFIX);
4450
}
4551

46-
private function freeProperty(\PHPUnit_Framework_Test $test, \ReflectionProperty $property)
52+
private function freeProperty(\PHPUnit\Framework\Test $test, \ReflectionProperty $property)
4753
{
4854
$property->setAccessible(true);
4955
$property->setValue($test, null);
5056
}
51-
52-
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) {}
53-
54-
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
55-
56-
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) {}
57-
58-
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
59-
60-
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
61-
62-
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) {}
63-
64-
public function startTest(\PHPUnit_Framework_Test $test) {}
65-
66-
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
67-
68-
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) {}
6957
}
7058

7159
class NeverIgnoreTestPolicy implements IgnoreTestPolicy

tests/TestListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use MyBuilder\PhpunitAccelerator\TestListener;
44
use MyBuilder\PhpunitAccelerator\IgnoreTestPolicy;
55

6-
class TestListenerTest extends \PHPUnit_Framework_TestCase
6+
class TestListenerTest extends \PHPUnit\Framework\TestCase
77
{
88
private $dummyTest;
99

@@ -63,7 +63,7 @@ private function assertDoesNotFreeTestProperty()
6363
}
6464
}
6565

66-
class PHPUnit_Fake extends \PHPUnit_Framework_TestCase
66+
class PHPUnit_Fake extends \PHPUnit\Framework\TestCase
6767
{
6868
public $phpUnitProperty = 1;
6969
}

0 commit comments

Comments
 (0)