Skip to content

Commit

Permalink
Merge pull request #3 from voryx/static-react
Browse files Browse the repository at this point in the history
Use static react loop when available
  • Loading branch information
davidwdan authored Oct 21, 2021
2 parents 9430954 + 9784571 commit c15ed6d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
],
"license": "MIT",
"authors": [
{
"name": "Matt Bonneau", "email": "[email protected]", "role": "Developer"
{
"name": "Matt Bonneau", "email": "[email protected]", "role": "Developer"
},
{
"name": "David Dan", "email": "[email protected]", "role": "Developer"
{
"name": "David Dan", "email": "[email protected]", "role": "Developer"
}
],
"require": {
"react/event-loop": "^1.0 || ^0.5 || ^0.4.1"
},
"require-dev": {
"phpunit/phpunit": "^6"
},
"autoload": {
"psr-4": {
"EventLoop\\": "src"
Expand All @@ -37,5 +34,8 @@
"psr-4": {
"EventLoop\\Tests\\": "tests"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5 | ^8"
}
}
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Global EventLoop">
<directory>tests/</directory>
</testsuite>
</testsuites>

</phpunit>
</phpunit>
3 changes: 2 additions & 1 deletion src/EventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EventLoop;

use React\EventLoop\Factory;
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;

class EventLoop
Expand All @@ -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();

Expand Down
8 changes: 3 additions & 5 deletions tests/Unit/EventLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private function resetStaticLoop() {
$prop->setAccessible(false);
}

public function setup() {
public function setup() : void {
$this->resetStaticLoop();
}

Expand Down Expand Up @@ -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());
Expand All @@ -56,4 +54,4 @@ public function testSettingDifferentInstance() {
public function testGetLoopTwice() {
$this->assertSame(\EventLoop\getLoop(), \EventLoop\getLoop());
}
}
}

0 comments on commit c15ed6d

Please sign in to comment.