Skip to content
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

fix: support stdClass in MockServerStreamingCall #359

Merged
merged 3 commits into from
Jan 19, 2022
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
7 changes: 6 additions & 1 deletion src/Testing/MockServerStreamingCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Google\ApiCore\ApiStatus;
use Google\Rpc\Code;
use Google\Rpc\Status;
use stdClass;

/**
* The MockServerStreamingCall class is used to mock out the \Grpc\ServerStreamingCall class
Expand All @@ -52,14 +53,18 @@ class MockServerStreamingCall extends \Grpc\ServerStreamingCall
* MockServerStreamingCall constructor.
* @param mixed[] $responses A list of response objects.
* @param callable|null $deserialize An optional deserialize method for the response object.
* @param MockStatus|null $status An optional status object. If set to null, a status of OK is used.
* @param MockStatus|stdClass|null $status An optional status object. If set to null, a status of OK is used.
*/
public function __construct($responses, $deserialize = null, $status = null)
{
$this->responses = $responses;
$this->deserialize = $deserialize;
if (is_null($status)) {
$status = new MockStatus(Code::OK, 'OK', []);
} elseif ($status instanceof stdClass) {
if (!property_exists($status, 'metadata')) {
$status->metadata = [];
}
}
$this->status = $status;
}
Expand Down