Skip to content

Commit

Permalink
Merge pull request #139 from Nekland/feature/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
Nek- authored Aug 2, 2018
2 parents 70b9f09 + 9e2758a commit c3653dc
Show file tree
Hide file tree
Showing 30 changed files with 85 additions and 51 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
}
},
"require": {
"react/event-loop": "~0.4.0",
"react/socket": "~0.8.0",
"php": "^7.0",
"react/event-loop": "^1.0.0",
"react/socket": "^1.0.0",
"nekland/tools": "^1.0",
"psr/log": "^1.0",
"react/dns": "^0.4.6"
},
"require-dev": {
"phpunit/phpunit": "^5.3"
"phpunit/phpunit": "^6.0"
},
"config": {
"bin-dir": "bin"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Nekland Woketo">
<directory suffix="Test.php">./tests</directory>
<directory suffix="Test.php">./tests/Woketo</directory>
</testsuite>
</testsuites>

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function processMessage(string $data)
{
// It may be a timeout going (we were waiting for data), let's clear it.
if ($this->timeout !== null) {
$this->timeout->cancel();
$this->loop->cancelTimer($this->timeout);
$this->timeout = null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use React\EventLoop\LoopInterface;
use React\EventLoop\Timer\TimerInterface;
use React\EventLoop\TimerInterface;
use React\Socket\Connection;
use React\Socket\ConnectionInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Server/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function processMessage(string $data)
{
// It may be a timeout going (we were waiting for data), let's clear it.
if ($this->timeout !== null) {
$this->timeout->cancel();
$this->loop->cancelTimer($this->timeout);
$this->timeout = null;
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Client/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Nekland\Woketo\Http\Url;
use Nekland\Woketo\Message\MessageHandlerInterface;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\EventLoop\LoopInterface;
use React\EventLoop\StreamSelectLoop;
Expand All @@ -21,7 +22,7 @@
* For the full license, take a look to the LICENSE file
* on the root directory of this project
*/
class ConnectionTest extends \PHPUnit_Framework_TestCase
class ConnectionTest extends TestCase
{
public function testItProcessHandshake()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Client/ConnectorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@


use Nekland\Woketo\Client\ConnectorFactory;
use PHPUnit\Framework\TestCase;
use React\EventLoop\LoopInterface;
use React\Socket\TimeoutConnector;

class ConnectorFactoryTest extends \PHPUnit_Framework_TestCase
class ConnectorFactoryTest extends TestCase
{
public function testItBuildATimeoutConnector()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/Woketo/Client/WebSocketClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
use Nekland\Woketo\Client\WebSocketClient;
use Nekland\Woketo\Core\AbstractConnection;
use Nekland\Woketo\Message\TextMessageHandler;
use PHPUnit\Framework\TestCase;

class WebSocketClientTest extends \PHPUnit_Framework_TestCase
class WebSocketClientTest extends TestCase
{
public function testItInstanciateWithoutConfiguration()
{
$client = new WebSocketClient('ws://localhost:8000');
$this->assertInstanceOf(WebSocketClient::class, $client);
}

public function testItCannotStartWithXdebug()
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Http/HttpHeadersBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace Test\Woketo\Http;

use Nekland\Woketo\Http\HttpHeadersBag;
use PHPUnit\Framework\TestCase;

class HttpHeadersBagTest extends \PHPUnit_Framework_TestCase
class HttpHeadersBagTest extends TestCase
{
public function testItKeepAndRetrieveHeaders()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace Test\Woketo\Http;

use Nekland\Woketo\Http\Request;
use PHPUnit\Framework\TestCase;

class RequestTest extends \PHPUnit_Framework_TestCase
class RequestTest extends TestCase
{
public function testAccessors()
{
Expand Down
8 changes: 6 additions & 2 deletions tests/Woketo/Http/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

use Nekland\Woketo\Exception\Http\HttpException;
use Nekland\Woketo\Http\Response;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

class ResponseTest extends \PHPUnit_Framework_TestCase
class ResponseTest extends TestCase
{
/**
* @var \React\Stream\Stream
* @var \React\Stream\DuplexStreamInterface
*/
private $stream;

Expand Down Expand Up @@ -52,7 +54,9 @@ public function testItGenerateResponseForWebsocket()
$response = Response::createSwitchProtocolResponse();
$response->addHeader('Sec-WebSocket-Accept', 's3pPLMBiTxaQ9kYGzzhZRbK+xOo=');

$this->stream->write(Argument::any())->shouldBeCalled();
$this->stream = $this->stream->reveal();

$response->send($this->stream);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Http/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@


use Nekland\Woketo\Http\Url;
use PHPUnit\Framework\TestCase;

class UrlTest extends \PHPUnit_Framework_TestCase
class UrlTest extends TestCase
{
public function testItUnderstandUrlAndIsAbleToReturnIt()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Message/BinaryMessageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Nekland\Woketo\Exception\UnsupportedException;
use Nekland\Woketo\Message\BinaryMessageHandler;
use Nekland\Woketo\Server\Connection;
use PHPUnit\Framework\TestCase;

class BinaryMessageHandlerTest extends \PHPUnit_Framework_TestCase
class BinaryMessageHandlerTest extends TestCase
{
public function testItThrowExceptionOnTextMessage()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Message/SimpleMessageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
use Nekland\Woketo\Exception\WebsocketException;
use Nekland\Woketo\Message\SimpleMessageHandler;
use Nekland\Woketo\Server\Connection;
use PHPUnit\Framework\TestCase;

class SimpleMessageHandlerTest extends \PHPUnit_Framework_TestCase
class SimpleMessageHandlerTest extends TestCase
{
private $instance;

Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Message/TextMessageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Nekland\Woketo\Exception\UnsupportedException;
use Nekland\Woketo\Message\TextMessageHandler;
use Nekland\Woketo\Server\Connection;
use PHPUnit\Framework\TestCase;

class TextMessageHandlerTest extends \PHPUnit_Framework_TestCase
class TextMessageHandlerTest extends TestCase
{
public function testItThrowsExceptionOnBinary()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/FrameFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Nekland\Woketo\Rfc6455\FrameFactory;
use Nekland\Woketo\Rfc6455\Message;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;

class FrameFactoryTest extends \PHPUnit_Framework_TestCase
class FrameFactoryTest extends TestCase
{
/**
* @var FrameFactory
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/FrameHandler/CloseFrameHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
use Nekland\Woketo\Rfc6455\FrameHandler\CloseFrameHandler;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\Socket\ConnectionInterface;

class CloseFrameHandlerTest extends \PHPUnit_Framework_TestCase
class CloseFrameHandlerTest extends TestCase
{
public function testItProcessCloseFrame()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/FrameHandler/PingFrameHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
use Nekland\Woketo\Rfc6455\FrameHandler\PingFrameHandler;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\Socket\ConnectionInterface;

class PingFrameHandlerTest extends \PHPUnit_Framework_TestCase
class PingFrameHandlerTest extends TestCase
{
public function testItSupportsPingFrame()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
use Nekland\Woketo\Rfc6455\FrameHandler\RsvCheckFrameHandler;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\Socket\ConnectionInterface;

class RsvCheckFrameHandlerTest extends \PHPUnit_Framework_TestCase
class RsvCheckFrameHandlerTest extends TestCase
{
public function testItCloseFrameOnRsvInvalid()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
use Nekland\Woketo\Rfc6455\FrameHandler\WrongOpcodeFrameHandler;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\Socket\ConnectionInterface;

class WrongOpcodeFrameHandlerTest extends \PHPUnit_Framework_TestCase
class WrongOpcodeFrameHandlerTest extends TestCase
{
/**
* @dataProvider getFrameWithWrongOpCode
Expand Down
8 changes: 5 additions & 3 deletions tests/Woketo/Rfc6455/FrameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
use Nekland\Woketo\Exception\Frame\TooBigFrameException;
use Nekland\Woketo\Rfc6455\Frame;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;

/**
* Class FrameTest
*
* These tests uses examples from the RFC:
* https://tools.ietf.org/html/rfc6455#section-5.7
*/
class FrameTest extends \PHPUnit_Framework_TestCase
class FrameTest extends TestCase
{
public function setUp()
{
Expand Down Expand Up @@ -192,6 +193,7 @@ public function testMaxFrameSizeIsConfigurable()
$rawData = BitManipulation::hexArrayToString('81', '7F', '00', '00', '00', '00', '00', '13', '00', '01') . $payload;

$frame = new Frame($rawData, ['maxPayloadSize' => 4194304]); // Allow 4Mo
$this->assertInstanceOf(Frame::class, $frame);
}

public function testItSupportsFrameWith65536PayloadFromRawData()
Expand Down Expand Up @@ -234,14 +236,14 @@ public function testItChecksAGoodFrameText()
{
$frame = BitManipulation::hexArrayToString(['81', '9d', '22', '4a', '47', '4d', '6a', '2f', '2b', '21', '4d', '67', '85', 'f8', '62', '89', 'd8', '8e', '94', '89', 'e3', '8e', '9e', '89', 'e7', '8e', '83', '67', '12', '19', '64', '67', '7f', '6c', '03']);
$frame = new Frame($frame);
Frame::checkFrame($frame);
$this->assertNull(Frame::checkFrame($frame));
}

public function testItChecksAGoodControlFrame()
{
$frame = BitManipulation::hexArrayToString(['89','88','b5','c7','6d','58','b5','38','93','a5','49','3c','6d','a7']);
$frame = new Frame($frame);
Frame::checkFrame($frame);
$this->assertNull(Frame::checkFrame($frame));
}

public function testItThrowsTooBigControlFrame()
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/Handshake/ClientHandshakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
use Nekland\Woketo\Http\Request;
use Nekland\Woketo\Http\Response;
use Nekland\Woketo\Rfc6455\Handshake\ClientHandshake;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

class ClientHandshakeTest extends \PHPUnit_Framework_TestCase
class ClientHandshakeTest extends TestCase
{
public function testItSignWith16BytesKeys()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/Handshake/ServerHandshakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Nekland\Woketo\Http\Request;
use Nekland\Woketo\Http\Response;
use Nekland\Woketo\Rfc6455\Handshake\ServerHandshake;
use PHPUnit\Framework\TestCase;

class ServerHandshakeTest extends \PHPUnit_Framework_TestCase
class ServerHandshakeTest extends TestCase
{
public function testItSignWebSocket()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/MessageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

use Nekland\Woketo\Rfc6455\Message;
use Nekland\Woketo\Rfc6455\MessageFactory;
use PHPUnit\Framework\TestCase;

class MessageFactoryTest extends \PHPUnit_Framework_TestCase
class MessageFactoryTest extends TestCase
{
public function testItCreateMessages()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Woketo/Rfc6455/MessageProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
use Nekland\Woketo\Rfc6455\FrameHandler\Rfc6455FrameHandlerInterface;
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\Socket\ConnectionInterface;

class MessageProcessorTest extends \PHPUnit_Framework_TestCase
class MessageProcessorTest extends TestCase
{
private $socket;
private $frameFactory;
Expand Down
5 changes: 3 additions & 2 deletions tests/Woketo/Rfc6455/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Nekland\Woketo\Rfc6455\Frame;
use Nekland\Woketo\Rfc6455\Message;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;

class MessageTest extends \PHPUnit_Framework_TestCase
class MessageTest extends TestCase
{
public function testItStackFramesAndReturnCompleteMessage()
{
Expand Down Expand Up @@ -125,7 +126,7 @@ public function testItHasConfigurableMaxMessages()
for($i = 0; $i <= 1000; $i++) {
$frame = new Frame();
$frame->setFinal(false);
$message->addFrame($frame);
$this->assertInstanceOf(Message::class, $message->addFrame($frame));
}
}
}
3 changes: 2 additions & 1 deletion tests/Woketo/Server/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
use Nekland\Woketo\Rfc6455\MessageProcessor;
use Nekland\Woketo\Server\Connection;
use Nekland\Woketo\Utils\BitManipulation;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use React\EventLoop\LoopInterface;
use React\Socket\ConnectionInterface;
use React\Stream\WritableStreamInterface;

class ConnectionTest extends \PHPUnit_Framework_TestCase
class ConnectionTest extends TestCase
{
public function testItSupportsTextMessage()
{
Expand Down
Loading

0 comments on commit c3653dc

Please sign in to comment.