Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
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
19 changes: 15 additions & 4 deletions tests/SocketIO/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class ParserTest extends TestCase
{
protected static $server;

public function testEncode()
{
$event = 'foo';
Expand Down Expand Up @@ -52,7 +54,7 @@ public function testDecode()
public function testExecute()
{
$frame = m::mock(Frame::class);
$server = new Server('0.0.0.0');
$server = $this->getServer();

$app = App::shouldReceive('call')->once();

Expand All @@ -68,11 +70,11 @@ public function testHeartbeatStrategy()
$frame->data = $payload;
$frame->fd = 1;

// // will lead to mockery bug
// $server = m::mock(swoole_websocket_server::class);
// will lead to mockery bug
// $server = m::mock(Server::class);
// $server->shouldReceive('push')->once();

$server = new Server('0.0.0.0');
$server = $this->getServer();

$strategy = new HeartbeatStrategy;
$this->assertFalse($strategy->handle($server, $frame));
Expand All @@ -84,4 +86,13 @@ public function testHeartbeatStrategy()
// $frame->data = '2probe';
// $this->assertTrue($strategy->handle($server, $frame));
}

protected function getServer()
{
if (static::$server) {
return static::$server;
}

return static::$server = new Server('0.0.0.0');
}
}