Copied!

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

The MockUnaryCall 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.

  • internal
CloneableInstantiable
Methods
public __construct( $response = NULL, $deserialize = NULL, ?stdClass $status = NULL)
 

MockUnaryCall constructor.

  • param \Message|string|null $response The response object.
  • param callable|array|null $deserialize An optional deserialize method for the response object.
  • param \stdClass|null $status An optional status object. If set to null, a status of OK is used.
public Grpc\AbstractCall::cancel()
 

Cancels the call.

public Grpc\UnaryCall::getMetadata()
 
  • return mixed The metadata sent by the server
public Grpc\AbstractCall::getPeer()
 
  • return string The URI of the endpoint
public Grpc\AbstractCall::getTrailingMetadata()
 
  • return mixed The trailing metadata sent by the server
public Grpc\AbstractCall::setCallCredentials( $call_credentials)
 

Set the CallCredentials for the underlying Call.

  • param \CallCredentials $call_credentials The CallCredentials object
public Grpc\UnaryCall::start( $data, array $metadata = [], array $options = [])
 

Start the call.

  • param mixed $data The data to send
  • param array $metadata Metadata to send with the call, if applicable (optional)
  • param array $options An array of options, possible keys: 'flags' => a number (optional)
public wait()
 

Immediately return the preset response object and status.

  • return array The response object and status.
Properties
protected Grpc\AbstractCall::$call = NULL
 
  • var \Call
protected Grpc\AbstractCall::$deserialize = NULL
protected Grpc\AbstractCall::$metadata = NULL
protected Grpc\AbstractCall::$trailing_metadata = NULL
Methods
protected Grpc\AbstractCall::_deserializeResponse( $value)
 

Deserialize a response value to an object.

  • param string $value The binary value to deserialize
  • return mixed The deserialized value
protected Grpc\AbstractCall::_serializeMessage( $data)
 

Serialize a message to the protobuf binary format.

  • param mixed $data The Protobuf message
  • return string The protobuf binary format
protected deserializeMessage( $message, $deserialize)
 
  • param mixed $message
  • param mixed $deserialize
Properties
private $response = NULL
private $status = NULL
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration