diff --git a/.gitattributes b/.gitattributes
index 0925d33..eccc763 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3,4 +3,5 @@
/.travis.yml export-ignore
/examples/ export-ignore
/phpunit.xml.dist export-ignore
+/phpunit.xml.legacy export-ignore
/tests/ export-ignore
diff --git a/.travis.yml b/.travis.yml
index 0a5430e..5623330 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,7 @@ language: php
# lock distro so new future defaults will not break the build
dist: trusty
-matrix:
+jobs:
include:
- php: 5.3
dist: precise
@@ -19,10 +19,9 @@ matrix:
allow_failures:
- php: hhvm-3.18
-sudo: false
-
install:
- - composer install --no-interaction
+ - composer install
script:
- - vendor/bin/phpunit --coverage-text
+ - if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
+ - if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
diff --git a/composer.json b/composer.json
index 365cd04..860ff6c 100644
--- a/composer.json
+++ b/composer.json
@@ -24,6 +24,6 @@
"react/promise-timer": "^1.1"
},
"require-dev": {
- "phpunit/phpunit": "^9.0 || ^5.0 || ^4.8"
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8"
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index ad03596..df94cae 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,14 +1,19 @@
-
+
+
- ./tests
+ ./tests/
-
-
- ./src
-
-
-
\ No newline at end of file
+
+
+ ./src/
+
+
+
diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy
new file mode 100644
index 0000000..36c0a9b
--- /dev/null
+++ b/phpunit.xml.legacy
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ ./tests/
+
+
+
+
+ ./src/
+
+
+
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 9d43486..2ba45e5 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -53,7 +53,13 @@ protected function expectCallableOnceValue($type)
*/
protected function createCallableMock()
{
- return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
+ if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
+ // PHPUnit 9+
+ return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
+ } else {
+ // legacy PHPUnit 4 - PHPUnit 8
+ return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
+ }
}
protected function createConnectionManagerMock($ret)
@@ -86,16 +92,20 @@ protected function assertPromiseReject($promise)
$promise->then($this->expectCallableNever(), $this->expectCallableOnce());
}
- public function setExpectedException($exception, $message = '', $code = 0)
+ public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
{
if (method_exists($this, 'expectException')) {
+ // PHPUnit 5+
$this->expectException($exception);
- if ($message !== '') {
- $this->expectExceptionMessage($message);
+ if ($exceptionMessage !== '') {
+ $this->expectExceptionMessage($exceptionMessage);
+ }
+ if ($exceptionCode !== null) {
+ $this->expectExceptionCode($exceptionCode);
}
- $this->expectExceptionCode($code);
} else {
- parent::setExpectedException($exception, $message, $code);
+ // legacy PHPUnit 4
+ parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
}
}
}