diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0925d33a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/examples/ export-ignore +/phpunit.xml.dist export-ignore +/tests/ export-ignore diff --git a/.travis.yml b/.travis.yml index eb5a9cdc..e1421bc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,26 @@ language: php -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm +# lock distro so new future defaults will not break the build +dist: trusty -before_install: - - composer self-update +jobs: + include: + - php: 5.3 + dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + - php: 7.3 + - php: 7.4 + - php: hhvm-3.18 + allow_failures: + - php: hhvm-3.18 install: - - composer install --prefer-source + - composer install script: - - phpunit -v --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/composer.json b/composer.json index 7e1caffb..2e1f1cd8 100644 --- a/composer.json +++ b/composer.json @@ -8,12 +8,20 @@ "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35" + }, "autoload": { - "psr-0": { - "React\\Promise": "src/" + "psr-4": { + "React\\Promise\\": "src/React/Promise/" }, "files": ["src/React/Promise/functions_include.php"] }, + "autoload-dev": { + "psr-4": { + "React\\Tests\\Promise\\": "tests/React/Promise/" + } + }, "extra": { "branch-alias": { "dev-master": "1.1-dev" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0f98aea7..8ce12cfa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,6 @@ - + ./tests/React/Promise/ diff --git a/tests/React/Promise/DeferredProgressTest.php b/tests/React/Promise/DeferredProgressTest.php index 838105da..44875781 100644 --- a/tests/React/Promise/DeferredProgressTest.php +++ b/tests/React/Promise/DeferredProgressTest.php @@ -1,6 +1,8 @@ setExpectedException('InvalidArgumentException'); new Deferred(false); } } diff --git a/tests/React/Promise/ErrorCollector.php b/tests/React/Promise/ErrorCollector.php index 648ab68a..dcc21946 100644 --- a/tests/React/Promise/ErrorCollector.php +++ b/tests/React/Promise/ErrorCollector.php @@ -1,6 +1,6 @@ errors, true); - throw new \PHPUnit_Framework_AssertionFailedError($message); + throw new \PHPUnit\Framework\AssertionFailedError($message); } } diff --git a/tests/React/Promise/FulfilledPromiseTest.php b/tests/React/Promise/FulfilledPromiseTest.php index fb1fafce..13777258 100644 --- a/tests/React/Promise/FulfilledPromiseTest.php +++ b/tests/React/Promise/FulfilledPromiseTest.php @@ -1,6 +1,9 @@ setExpectedException('\InvalidArgumentException'); + $this->setExpectedException('InvalidArgumentException'); new Promise(null); } @@ -93,10 +95,10 @@ public function shouldInvokeCancellationHandlerAndStayPendingWhenCallingCancel() /** * @test - * @expectedException InvalidArgumentException */ public function shouldThrowIfCancellerIsNotACallable() { + $this->setExpectedException('InvalidArgumentException'); new Promise(function () { }, false); } } diff --git a/tests/React/Promise/RejectedPromiseTest.php b/tests/React/Promise/RejectedPromiseTest.php index d2cb860f..1b5dc84c 100644 --- a/tests/React/Promise/RejectedPromiseTest.php +++ b/tests/React/Promise/RejectedPromiseTest.php @@ -1,6 +1,9 @@ getMockBuilder('React\\Promise\Stub\CallableStub') - ->getMock(); + if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) { + // PHPUnit 9+ + return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock(); + } else { + // legacy PHPUnit 4 - PHPUnit 9 + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); + } } public function invalidCallbackDataProvider() @@ -52,4 +56,21 @@ public function invalidCallbackDataProvider() 'falsey' => array(0) ); } + + public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null) + { + if (method_exists($this, 'expectException')) { + // PHPUnit 5+ + $this->expectException($exception); + if ($exceptionMessage !== '') { + $this->expectExceptionMessage($exceptionMessage); + } + if ($exceptionCode !== null) { + $this->expectExceptionCode($exceptionCode); + } + } else { + // legacy PHPUnit 4 + parent::setExpectedException($exception, $exceptionMessage, $exceptionCode); + } + } } diff --git a/tests/React/Promise/UtilPromiseForTest.php b/tests/React/Promise/UtilPromiseForTest.php index cdadf2e3..49b70e77 100644 --- a/tests/React/Promise/UtilPromiseForTest.php +++ b/tests/React/Promise/UtilPromiseForTest.php @@ -1,6 +1,10 @@ add('React\Promise', __DIR__);