diff --git a/src/Testing/MockServerStreamingCall.php b/src/Testing/MockServerStreamingCall.php index 7e8da83be..9e8ef658c 100644 --- a/src/Testing/MockServerStreamingCall.php +++ b/src/Testing/MockServerStreamingCall.php @@ -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 @@ -52,7 +53,7 @@ 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) { @@ -60,6 +61,10 @@ public function __construct($responses, $deserialize = null, $status = null) $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; }