Skip to content

Commit

Permalink
fix: support stdClass in MockServerStreamingCall (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Jan 19, 2022
1 parent d5ea88c commit 46ffa1f
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 46ffa1f

Please sign in to comment.