diff --git a/.travis.yml b/.travis.yml index 6c0dc15..3d9ebc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,14 +6,9 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm dist: trusty -matrix: - allow_failures: - - php: hhvm - before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "session.serialize_handler = php" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - php -m diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 284fbde..e20115f 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -2,6 +2,7 @@ namespace Ratchet\Server; use Ratchet\Server\IoServer; use React\EventLoop\StreamSelectLoop; +use React\EventLoop\LoopInterface; use React\Socket\Server; /** @@ -16,6 +17,14 @@ class IoServerTest extends \PHPUnit_Framework_TestCase { protected $reactor; + protected function tickLoop(LoopInterface $loop) { + $loop->futureTick(function () use ($loop) { + $loop->stop(); + }); + + $loop->run(); + } + public function setUp() { $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); @@ -32,7 +41,7 @@ class IoServerTest extends \PHPUnit_Framework_TestCase { $client = stream_socket_client("tcp://localhost:{$this->port}"); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); //$this->assertTrue(is_string($this->app->last['onOpen'][0]->remoteAddress)); //$this->assertTrue(is_int($this->app->last['onOpen'][0]->resourceId)); @@ -52,16 +61,16 @@ class IoServerTest extends \PHPUnit_Framework_TestCase { socket_set_block($client); socket_connect($client, 'localhost', $this->port); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); socket_write($client, $msg); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); socket_shutdown($client, 1); socket_shutdown($client, 0); socket_close($client); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); } public function testOnClose() { @@ -73,13 +82,13 @@ class IoServerTest extends \PHPUnit_Framework_TestCase { socket_set_block($client); socket_connect($client, 'localhost', $this->port); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); socket_shutdown($client, 1); socket_shutdown($client, 0); socket_close($client); - $this->server->loop->tick(); + $this->tickLoop($this->server->loop); } public function testFactory() {