MockTransport
class MockTransport implements TransportInterface (View source)
internal |
Traits
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.
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.
Creates a sequence such that the responses are returned in order.
No description
No description
Closes the connection, if one exists.
Details
__construct(callable $deserialize = null)
No description
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
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
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.
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.
static
stripStatusFromResponses($responses)
No description
addResponse(Message $response, stdClass $status = null)
Add a response object, and an optional status, to the list of responses to be returned via _simpleRequest.
setStreamingStatus(stdClass $status)
Set the status object to be used when creating streaming calls.
ReceivedRequest[]
popReceivedCalls()
Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.
int
getReceivedCallCount()
No description
array
popCallObjects()
No description
bool
isExhausted()
No description
static MockStubTrait
create(mixed $responseObject, stdClass $status = null, callable $deserialize = null)
No description
static MockStubTrait
createWithResponseSequence(array $sequence, callable $deserialize = null, stdClass $finalStatus = null)
Creates a sequence such that the responses are returned in order.
setAgentHeaderDescriptor($agentHeaderDescriptor)
No description
PromiseInterface
startUnaryCall(Call $call, array $options)
Returns a promise used to execute network requests.
BidiStream
startBidiStreamingCall(Call $call, array $options)
Starts a bidi streaming call.
ClientStream
startClientStreamingCall(Call $call, array $options)
Starts a client streaming call.
ServerStream
startServerStreamingCall(Call $call, array $options)
Starts a server streaming call.
__call(string $name, array $arguments)
No description
void
close()
Closes the connection, if one exists.