diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7d496d8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + pull_request: + +jobs: + PHPUnit: + name: PHPUnit (PHP ${{ matrix.php }} on ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-20.04 + php: + - 8.0 + - 7.4 + - 7.3 + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + - run: composer install + - run: vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e76e2c9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: php - -matrix: - include: - - php: 7.0 - env: - - qaExtended=true - - php: 7.1 - - php: 7.2 - env: - - dropPlatform=false - - php: nightly - env: - - dropPlatform=false - - php: 7.0 - env: - - dependencies=lowest - - php: 7.1 - env: - - dependencies=lowest - - php: 7.2 - env: - - dependencies=lowest - - dropPlatform=false - - php: nightly - env: - - dependencies=lowest - - dropPlatform=false - - php: 7.0 - env: - - dependencies=highest - - php: 7.1 - env: - - dependencies=highest - - php: 7.2 - env: - - dependencies=highest - - dropPlatform=false - - php: nightly - env: - - dependencies=highest - - dropPlatform=false - -before_script: composer install - -script: - - vendor/bin/phpunit diff --git a/composer.json b/composer.json index 1e54aa7..3faa57b 100644 --- a/composer.json +++ b/composer.json @@ -11,19 +11,16 @@ ], "license": "MIT", "authors": [ - { - "name": "Matt Bonneau", "email": "matt@bonneau.net", "role": "Developer" + { + "name": "Matt Bonneau", "email": "matt@bonneau.net", "role": "Developer" }, - { - "name": "David Dan", "email": "davidwdan@gmail.com", "role": "Developer" + { + "name": "David Dan", "email": "davidwdan@gmail.com", "role": "Developer" } ], "require": { "react/event-loop": "^1.0 || ^0.5 || ^0.4.1" }, - "require-dev": { - "phpunit/phpunit": "^6" - }, "autoload": { "psr-4": { "EventLoop\\": "src" @@ -37,5 +34,8 @@ "psr-4": { "EventLoop\\Tests\\": "tests" } + }, + "require-dev": { + "phpunit/phpunit": "^9.5 | ^8" } } diff --git a/phpunit.xml b/phpunit.xml index 0be80b0..12086cb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" > @@ -16,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/EventLoop.php b/src/EventLoop.php index 44a9fdc..105ac12 100644 --- a/src/EventLoop.php +++ b/src/EventLoop.php @@ -3,6 +3,7 @@ namespace EventLoop; use React\EventLoop\Factory; +use React\EventLoop\Loop; use React\EventLoop\LoopInterface; class EventLoop @@ -27,7 +28,7 @@ static public function getLoop() { return static::$loop; } - static::$loop = Factory::create(); + static::$loop = class_exists('React\EventLoop\Loop') ? Loop::get() : Factory::create(); static::registerLoopRunner(); diff --git a/tests/Unit/EventLoopTest.php b/tests/Unit/EventLoopTest.php index d15170c..d302a55 100644 --- a/tests/Unit/EventLoopTest.php +++ b/tests/Unit/EventLoopTest.php @@ -16,7 +16,7 @@ private function resetStaticLoop() { $prop->setAccessible(false); } - public function setup() { + public function setup() : void { $this->resetStaticLoop(); } @@ -44,10 +44,8 @@ public function testGetLoopWithoutSet() { $this->assertSame($loop, \EventLoop\getLoop()); } - /** - * @expectedException \Exception - */ public function testSettingDifferentInstance() { + $this->expectException(\Exception::class); \EventLoop\getLoop(); \EventLoop\setLoop(Factory::create()); @@ -56,4 +54,4 @@ public function testSettingDifferentInstance() { public function testGetLoopTwice() { $this->assertSame(\EventLoop\getLoop(), \EventLoop\getLoop()); } -} \ No newline at end of file +}