Beispiel #1
0
 public function testClientServerFullRequestResponse()
 {
     $deadline = Grpc\Timeval::inf_future();
     $req_text = 'client_server_full_request_response';
     $reply_text = 'reply:client_server_full_request_response';
     $status_text = 'status:client_server_full_response_text';
     $call = new Grpc\Call($this->channel, 'dummy_method', $deadline);
     $event = $call->start_batch([Grpc\OP_SEND_INITIAL_METADATA => [], Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, Grpc\OP_SEND_MESSAGE => $req_text]);
     $this->assertTrue($event->send_metadata);
     $this->assertTrue($event->send_close);
     $this->assertTrue($event->send_message);
     $event = $this->server->request_call();
     $this->assertSame('dummy_method', $event->method);
     $server_call = $event->call;
     $event = $server_call->start_batch([Grpc\OP_SEND_INITIAL_METADATA => [], Grpc\OP_SEND_MESSAGE => $reply_text, Grpc\OP_SEND_STATUS_FROM_SERVER => ['metadata' => [], 'code' => Grpc\STATUS_OK, 'details' => $status_text], Grpc\OP_RECV_MESSAGE => true, Grpc\OP_RECV_CLOSE_ON_SERVER => true]);
     $this->assertTrue($event->send_metadata);
     $this->assertTrue($event->send_status);
     $this->assertTrue($event->send_message);
     $this->assertFalse($event->cancelled);
     $this->assertSame($req_text, $event->message);
     $event = $call->start_batch([Grpc\OP_RECV_INITIAL_METADATA => true, Grpc\OP_RECV_MESSAGE => true, Grpc\OP_RECV_STATUS_ON_CLIENT => true]);
     $this->assertSame([], $event->metadata);
     $this->assertSame($reply_text, $event->message);
     $status = $event->status;
     $this->assertSame([], $status->metadata);
     $this->assertSame(Grpc\STATUS_OK, $status->code);
     $this->assertSame($status_text, $status->details);
     unset($call);
     unset($server_call);
 }