class MockClientStreamingCall extends ClientStreamingCall (View source)

The MockClientStreamingCall class is used to mock out the \Grpc\ClientStreamingCall class (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/ClientStreamingCall.php)

The MockClientStreamingCall object is constructed with a response object, an optional deserialize method, and an optional status. The response object and status are returned immediately from the wait() method. It also provides a write() method that accepts request objects, and a getAllRequests() method that returns all request objects passed to write(), and clears them.

Methods

__construct(Message $response, callable|null $deserialize = null, MockStatus|null $status = null)

MockClientStreamingCall constructor.

array
wait()

Immediately return the preset response object and status.

write(Message|mixed $request, array $options = [])

Save the request object, to be retrieved via getReceivedCalls()

array
popReceivedCalls()

Return a list of calls made to write(), and clear $receivedFuncCalls.

Details

__construct(Message $response, callable|null $deserialize = null, MockStatus|null $status = null)

MockClientStreamingCall constructor.

Parameters

Message $response The response object.
callable|null $deserialize An optional deserialize method for the response object.
MockStatus|null $status An optional status object. If set to null, a status of OK is used.

array wait()

Immediately return the preset response object and status.

Return Value

array The response object and status.

write(Message|mixed $request, array $options = [])

Save the request object, to be retrieved via getReceivedCalls()

Parameters

Message|mixed $request The request object
array $options An array of options

Exceptions

ApiException

array popReceivedCalls()

Return a list of calls made to write(), and clear $receivedFuncCalls.

Return Value

array An array of received requests