mockUnaryCall = new MockUnaryCall($response, $deserialize, $status); } /** * Immediately return the preset response object and status. * @return array The response object and status. */ public function wait() { $this->waitCalled = true; return $this->mockUnaryCall->wait(); } /** * Save the request object, to be retrieved via getReceivedCalls() * @param Message|mixed $request The request object * @param array $options An array of options * @throws ApiException */ public function write($request, array $options = []) { if ($this->waitCalled) { throw new ApiException('Cannot call write() after wait()', Code::INTERNAL, ApiStatus::INTERNAL); } if (is_a($request, '\Google\Protobuf\Internal\Message')) { /** @var Message $newRequest */ $newRequest = new $request(); $newRequest->mergeFromString($request->serializeToString()); $request = $newRequest; } $this->receivedWrites[] = $request; } /** * Return a list of calls made to write(), and clear $receivedFuncCalls. * * @return mixed[] An array of received requests */ public function popReceivedCalls() { $receivedFuncCallsTemp = $this->receivedWrites; $this->receivedWrites = []; return $receivedFuncCallsTemp; } }