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.
- internal
| Methods |
| public __construct(?callable $deserialize = NULL) |
| public _bidiRequest( $method, $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.
|
| public _clientStreamRequest( $method, $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
|
| public _serverStreamRequest( $method, $argument, $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.
|
| public _simpleRequest( $method, $argument, $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
|
| public addResponse( $response, ?stdClass $status = NULL) Add a response object, and an optional status, to the list of responses to be returned via _simpleRequest.
|
public static create( $responseObject, ?stdClass $status = NULL, ?callable $deserialize = NULL)
|
| public static createWithResponseSequence(array $sequence, ?callable $deserialize = NULL, ?stdClass $finalStatus = NULL) Creates a sequence such that the responses are returned in order.
|
public getReceivedCallCount()
|
public isExhausted()
|
public popCallObjects()
|
| public popReceivedCalls() Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.
|
| public setStreamingStatus(stdClass $status) Set the status object to be used when creating streaming calls.
|
| public static stripStatusFromResponses( $responses) |
| Properties |
| private $callObjects = [] |
| private $deserialize = NULL |
| private $receivedFuncCalls = [] |
| private $responses = [] |
| private $serverStreamingStatus = NULL |
| Methods |
public static create( $responseObject, ?stdClass $status = NULL, ?callable $deserialize = NULL)
|
| public static createWithResponseSequence(array $sequence, ?callable $deserialize = NULL, ?stdClass $finalStatus = NULL) Creates a sequence such that the responses are returned in order.
|
| public static stripStatusFromResponses( $responses) |