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 d728c44..75669ce 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "react/stream": "^1.0 || ^0.7" }, "require-dev": { - "phpunit/phpunit": "^9.0 || ^5.0 || ^4.8", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8", "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d0bb55e..b7a4c21 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,19 @@ - + + ./tests/ - - + + ./src/ - - - \ No newline at end of file + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..f6583ad --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,18 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + diff --git a/tests/TestCase.php b/tests/TestCase.php index 22be7e6..5fd9ac0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -51,6 +51,12 @@ protected function expectCallableOnceParameter($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(); + } } }