Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 3b816be

Browse files
committed
fix parser test in swoole 4.0
1 parent 82b0913 commit 3b816be

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/SocketIO/ParserTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
class ParserTest extends TestCase
1414
{
15+
protected static $server;
16+
1517
public function testEncode()
1618
{
1719
$event = 'foo';
@@ -52,7 +54,7 @@ public function testDecode()
5254
public function testExecute()
5355
{
5456
$frame = m::mock(Frame::class);
55-
$server = new Server('0.0.0.0');
57+
$server = $this->getServer();
5658

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

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

71-
// // will lead to mockery bug
72-
// $server = m::mock(swoole_websocket_server::class);
73+
// will lead to mockery bug
74+
// $server = m::mock(Server::class);
7375
// $server->shouldReceive('push')->once();
7476

75-
$server = new Server('0.0.0.0');
77+
$server = $this->getServer();
7678

7779
$strategy = new HeartbeatStrategy;
7880
$this->assertFalse($strategy->handle($server, $frame));
@@ -84,4 +86,13 @@ public function testHeartbeatStrategy()
8486
// $frame->data = '2probe';
8587
// $this->assertTrue($strategy->handle($server, $frame));
8688
}
89+
90+
protected function getServer()
91+
{
92+
if (static::$server) {
93+
return static::$server;
94+
}
95+
96+
return static::$server = new Server('0.0.0.0');
97+
}
8798
}

0 commit comments

Comments
 (0)