-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<phpunit | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="Global EventLoop"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace EventLoop\Tests; | ||
|
||
class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace EventLoop\Tests\Unit; | ||
|
||
use EventLoop\EventLoop; | ||
use EventLoop\Tests\TestCase; | ||
use React\EventLoop\Factory; | ||
|
||
class EventLoopTest extends TestCase | ||
{ | ||
private function resetStaticLoop() { | ||
$ref = new \ReflectionClass(EventLoop::class); | ||
$prop = $ref->getProperty('loop'); | ||
$prop->setAccessible(true); | ||
$prop->setValue(null); | ||
$prop->setAccessible(false); | ||
} | ||
|
||
public function setup() { | ||
$this->resetStaticLoop(); | ||
} | ||
|
||
public function testSetLoop() | ||
{ | ||
$loop = Factory::create(); | ||
|
||
\EventLoop\setLoop($loop); | ||
|
||
$this->assertSame($loop, \EventLoop\getLoop()); | ||
} | ||
|
||
public function testSetLoopSameInstance() | ||
{ | ||
$loop = \EventLoop\getLoop(); | ||
|
||
\EventLoop\setLoop($loop); | ||
|
||
$this->assertSame($loop, \EventLoop\getLoop()); | ||
} | ||
|
||
public function testGetLoopWithoutSet() { | ||
$loop = \EventLoop\getLoop(); | ||
|
||
$this->assertSame($loop, \EventLoop\getLoop()); | ||
} | ||
|
||
/** | ||
* @expectedException \Exception | ||
*/ | ||
public function testSettingDifferentInstance() { | ||
\EventLoop\getLoop(); | ||
|
||
\EventLoop\setLoop(Factory::create()); | ||
} | ||
|
||
public function testGetLoopTwice() { | ||
$this->assertSame(\EventLoop\getLoop(), \EventLoop\getLoop()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
$files = [ | ||
__DIR__ . '/../vendor/autoload.php', | ||
__DIR__ . '/../../vendor/autoload.php', | ||
__DIR__ . '/../../../vendor/autoload.php', | ||
__DIR__ . '/../../../../vendor/autoload.php', | ||
|
||
]; | ||
|
||
foreach ($files as $file) { | ||
if (file_exists($file)) { | ||
$loader = require_once $file; | ||
$loader->addPsr4('EventLoop\\Tests\\', __DIR__); | ||
break; | ||
} | ||
} |