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.

Trait
Methods
public __construct( $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, $status = NULL)
 
Add a response object, and an optional status, to the list of responses to be returned via _simpleRequest.

    public static create( $responseObject, $status = NULL, $deserialize = NULL)
     


    • return static An instance of the current class type.
    public static createWithResponseSequence( $sequence, $deserialize = NULL, $finalStatus = NULL)
     
    Creates a sequence such that the responses are returned in order.

    • return static An instance of the current class type.
    public getReceivedCallCount()
     


    • return int The number of calls received.
    public isExhausted()
     


    • return bool True if $receivedFuncCalls and $response are empty.
    public popCallObjects()
     


    • return array The call objects created by calls to the stub
    public popReceivedCalls()
     
    Return a list of calls made to _simpleRequest, and clear $receivedFuncCalls.

    • return ReceivedRequest[] An array of received requests
    public setStreamingStatus( $status)
     
    Set the status object to be used when creating streaming calls.

      public static stripStatusFromResponses( $responses)
      Properties
      private $callObjects
      private $deserialize
      private $receivedFuncCalls
      private $responses
      private $serverStreamingStatus
      Methods
      public static create( $responseObject, $status = NULL, $deserialize = NULL)
       


      • return static An instance of the current class type.
      public static createWithResponseSequence( $sequence, $deserialize = NULL, $finalStatus = NULL)
       
      Creates a sequence such that the responses are returned in order.

      • return static An instance of the current class type.
      public static stripStatusFromResponses( $responses)
      © 2020 Bruce Wells
      Search Namespaces \ Classes
      ConfigurationNumbers (0-9.) only