Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test suite forward compatibility with upcoming EventLoop releases #128

Merged
merged 1 commit into from
Dec 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"php": ">=5.3.8",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0"
},
"require-dev": {
Expand Down
58 changes: 50 additions & 8 deletions tests/DuplexResourceStreamIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,52 @@
namespace React\Tests\Stream;

use React\Stream\DuplexResourceStream;
use React\EventLoop as rel;
use React\Stream\ReadableResourceStream;
use React\EventLoop\ExtEventLoop;
use React\EventLoop\ExtLibeventLoop;
use React\EventLoop\ExtLibevLoop;
use React\EventLoop\LoopInterface;
use React\EventLoop\LibEventLoop;
use React\EventLoop\LibEvLoop;
use React\EventLoop\StreamSelectLoop;

class DuplexResourceStreamIntegrationTest extends TestCase
{
public function loopProvider()
{
return array(
array(function() { return true; }, function() { return new rel\StreamSelectLoop; }),
array(function() { return function_exists('event_base_new'); }, function() { return new rel\LibEventLoop; }),
array(function() { return class_exists('libev\EventLoop'); }, function() { return new rel\LibEvLoop; }),
array(function() { return class_exists('EventBase'); }, function() { return new rel\ExtEventLoop; })
array(
function() {
return true;
},
function () {
return new StreamSelectLoop();
}
),
array(
function () {
return function_exists('event_base_new');
},
function () {
return class_exists('React\EventLoop\ExtLibeventLoop') ? new ExtLibeventLoop() : LibEventLoop();
}
),
array(
function () {
return class_exists('libev\EventLoop');
},
function () {
return class_exists('React\EventLoop\ExtLibevLoop') ? new ExtLibevLoop() : new LibEvLoop();
}
),
array(
function () {
return class_exists('EventBase') && class_exists('React\EventLoop\ExtEventLoop');
},
function () {
return new ExtEventLoop();
}
)
);
}

Expand Down Expand Up @@ -44,9 +78,9 @@ public function testBufferReadsLargeChunks($condition, $loopFactory)

$streamA->write($testString);

$loop->tick();
$loop->tick();
$loop->tick();
$this->loopTick($loop);
$this->loopTick($loop);
$this->loopTick($loop);

$streamA->close();
$streamB->close();
Expand Down Expand Up @@ -307,4 +341,12 @@ public function testReadsNothingFromProcessPipeWithNoOutput($condition, $loopFac

$loop->run();
}

private function loopTick(LoopInterface $loop)
{
$loop->addTimer(0, function () use ($loop) {
$loop->stop();
});
$loop->run();
}
}