MockStubTrait
trait MockStubTrait
The MockStubTrait is used by generated mock stub classes which extent \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) It provides functionality to add responses, get received calls, and overrides the _simpleRequest method so that the elements of $responses are returned instead of making a call to the API.
Methods
Overrides the _simpleRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockUnaryCall object that will return the first item from $responses
Overrides the _clientStreamRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockClientStreamingCall object that will return the first item from $responses
Overrides the _serverStreamRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockServerStreamingCall object that will stream items from $responses, and return a final status of $serverStreamingStatus.
Overrides the _bidiRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockBidiStreamingCall object that will stream items from $responses, and return a final status of $serverStreamingStatus.
No description
Add a response object, and an optional status, to the list of responses to be returned via _simpleRequest.
Set the status object to be used when creating streaming calls.
Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.
No description
No description
No description
Details
at line 60
MockUnaryCall
_simpleRequest(string $method, Message $argument, callable $deserialize, array $metadata = [], array $options = [])
Overrides the _simpleRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockUnaryCall object that will return the first item from $responses
at line 95
MockClientStreamingCall
_clientStreamRequest(string $method, callable $deserialize, array $metadata = [], array $options = [])
Overrides the _clientStreamRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockClientStreamingCall object that will return the first item from $responses
at line 127
MockServerStreamingCall
_serverStreamRequest(string $method, Message $argument, callable $deserialize, array $metadata = [], array $options = [])
Overrides the _serverStreamRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockServerStreamingCall object that will stream items from $responses, and return a final status of $serverStreamingStatus.
at line 162
MockBidiStreamingCall
_bidiRequest(string $method, callable $deserialize, array $metadata = [], array $options = [])
Overrides the _bidiRequest method in \Grpc\BaseStub (https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/BaseStub.php) Returns a MockBidiStreamingCall object that will stream items from $responses, and return a final status of $serverStreamingStatus.
at line 177
static
stripStatusFromResponses($responses)
at line 193
addResponse(Message $response, Status $status = null)
Add a response object, and an optional status, to the list of responses to be returned via _simpleRequest.
at line 206
setStreamingStatus(Status $status)
Set the status object to be used when creating streaming calls.
at line 216
ReceivedRequest[]
popReceivedCalls()
Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.