-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Declare the reconnect parameter deprecated in the disconnect #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
use PHPUnit\Framework\TestCase; | ||
use RoadRunner\Centrifugo\CentrifugoApiInterface; | ||
use RoadRunner\Centrifugo\Exception\CentrifugoApiResponseException; | ||
use RoadRunner\Centrifugo\Payload\Disconnect; | ||
use RoadRunner\Centrifugo\RPCCentrifugoApi; | ||
use RoadRunner\Centrifugal\API\DTO\V1 as DTO; | ||
use Spiral\Goridge\RPC\Codec\ProtobufCodec; | ||
|
@@ -72,4 +73,56 @@ public function testPublishErrorHandling(): void | |
|
||
$this->api->publish(channel: 'foo-channel', message: \json_encode(['foo' => 'bar']), skipHistory: true, tags: ['baz', 'baf']); | ||
} | ||
|
||
public function testDisconnectWithDisconnectObject(): void | ||
{ | ||
$this->rpc->shouldReceive('call') | ||
->once() | ||
->withArgs(fn( | ||
string $method, | ||
DTO\DisconnectRequest $request, | ||
string $responseClass | ||
): bool => $method === 'centrifuge.Unsubscribe' | ||
&& $request->getUser() === 'foo-user' | ||
&& $request->getClient() === 'foo-client' | ||
&& $request->getSession() === 'foo-session' | ||
&& $request->getDisconnect()->getCode() === 400 | ||
&& $request->getDisconnect()->getReason() === 'foo-reason' | ||
&& $responseClass === DTO\DisconnectResponse::class | ||
) | ||
->andReturn(new DTO\DisconnectResponse); | ||
|
||
$this->api->disconnect( | ||
user: 'foo-user', | ||
client: 'foo-client', | ||
session: 'foo-session', | ||
disconnect: new Disconnect(code: 400, reason: 'foo-reason'), | ||
); | ||
} | ||
|
||
public function testDisconnectWithDisconnectObjectAndDeprecatedReconnect(): void | ||
{ | ||
$this->rpc->shouldReceive('call') | ||
->once() | ||
->withArgs(fn( | ||
string $method, | ||
DTO\DisconnectRequest $request, | ||
string $responseClass | ||
): bool => $method === 'centrifuge.Unsubscribe' | ||
&& $request->getUser() === 'foo-user' | ||
&& $request->getClient() === 'foo-client' | ||
&& $request->getSession() === 'foo-session' | ||
&& $request->getDisconnect()->getCode() === 400 | ||
&& $request->getDisconnect()->getReason() === 'foo-reason' | ||
&& $responseClass === DTO\DisconnectResponse::class | ||
) | ||
->andReturn(new DTO\DisconnectResponse); | ||
|
||
$this->api->disconnect( | ||
user: 'foo-user', | ||
client: 'foo-client', | ||
session: 'foo-session', | ||
disconnect: new Disconnect(code: 400, reason: 'foo-reason', reconnect: true), | ||
); | ||
Comment on lines
+103
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Consider adding a comment or documentation to clarify that this test is specifically for ensuring backward compatibility with the deprecated |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ public function testDisconnect(): void | |
{ | ||
$worker = $this->createWorker(function (Payload $arg) { | ||
$expects = new Payload((new ConnectResponse()) | ||
->setDisconnect(new Disconnect(['code' => 111, 'reason' => 'some', 'reconnect' => false])) | ||
->setDisconnect(new Disconnect(['code' => 111, 'reason' => 'some'])) | ||
->serializeToString() | ||
); | ||
|
||
|
@@ -115,11 +115,11 @@ public function testDisconnect(): void | |
$req->disconnect(111, 'some'); | ||
} | ||
|
||
public function testDisconnectWithReconnect(): void | ||
public function testDisconnectWithDeprecatedReconnect(): void | ||
{ | ||
$worker = $this->createWorker(function (Payload $arg) { | ||
$expects = new Payload((new ConnectResponse()) | ||
->setDisconnect(new Disconnect(['code' => 111, 'reason' => 'some', 'reconnect' => true])) | ||
->setDisconnect(new Disconnect(['code' => 111, 'reason' => 'some'])) | ||
->serializeToString() | ||
); | ||
|
||
Comment on lines
115
to
125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Consider adding a comment or documentation to clarify that this test is specifically for ensuring backward compatibility with the deprecated |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
disconnect
method documentation correctly indicates the deprecation of the$reconnect
parameter. However, the method still accepts and processes this parameter. As with theDisconnect
class, consider adding a deprecation warning when this parameter is used, to better inform developers of its impending removal.