|
|
|
@ -26,8 +26,8 @@ function hardAssert($value, $error_message) { |
|
|
|
|
*/ |
|
|
|
|
function emptyUnary($stub) { |
|
|
|
|
list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); |
|
|
|
|
hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result != null, 'Call completed with a null response'); |
|
|
|
|
hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result !== null, 'Call completed with a null response'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -49,14 +49,14 @@ function largeUnary($stub) { |
|
|
|
|
$request->setPayload($payload); |
|
|
|
|
|
|
|
|
|
list($result, $status) = $stub->UnaryCall($request)->wait(); |
|
|
|
|
hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result != null, 'Call returned a null response'); |
|
|
|
|
hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result !== null, 'Call returned a null response'); |
|
|
|
|
$payload = $result->getPayload(); |
|
|
|
|
hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
'Payload had the wrong type'); |
|
|
|
|
hardAssert(strlen($payload->getBody()) == $response_len, |
|
|
|
|
hardAssert(strlen($payload->getBody()) === $response_len, |
|
|
|
|
'Payload had the wrong length'); |
|
|
|
|
hardAssert($payload->getBody() == str_repeat("\0", $response_len), |
|
|
|
|
hardAssert($payload->getBody() === str_repeat("\0", $response_len), |
|
|
|
|
'Payload had the wrong content'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -78,8 +78,8 @@ function clientStreaming($stub) { |
|
|
|
|
}, $request_lengths); |
|
|
|
|
|
|
|
|
|
list($result, $status) = $stub->StreamingInputCall($requests)->wait(); |
|
|
|
|
hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result->getAggregatedPayloadSize() == 74922, |
|
|
|
|
hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); |
|
|
|
|
hardAssert($result->getAggregatedPayloadSize() === 74922, |
|
|
|
|
'aggregated_payload_size was incorrect'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -100,15 +100,15 @@ function serverStreaming($stub) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$call = $stub->StreamingOutputCall($request); |
|
|
|
|
hardAssert($call->getStatus()->code == Grpc\STATUS_OK, |
|
|
|
|
hardAssert($call->getStatus()->code === Grpc\STATUS_OK, |
|
|
|
|
'Call did not complete successfully'); |
|
|
|
|
$i = 0; |
|
|
|
|
foreach($call->responses() as $value) { |
|
|
|
|
hardAssert($i < 4, 'Too many responses'); |
|
|
|
|
$payload = $value->getPayload(); |
|
|
|
|
hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
'Payload ' . $i . ' had the wrong type'); |
|
|
|
|
hardAssert(strlen($payload->getBody()) == $sizes[$i], |
|
|
|
|
hardAssert(strlen($payload->getBody()) === $sizes[$i], |
|
|
|
|
'Response ' . $i . ' had the wrong length'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -136,16 +136,16 @@ function pingPong($stub) { |
|
|
|
|
$call->write($request); |
|
|
|
|
$response = $call->read(); |
|
|
|
|
|
|
|
|
|
hardAssert($response != null, 'Server returned too few responses'); |
|
|
|
|
hardAssert($response !== null, 'Server returned too few responses'); |
|
|
|
|
$payload = $response->getPayload(); |
|
|
|
|
hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, |
|
|
|
|
'Payload ' . $i . ' had the wrong type'); |
|
|
|
|
hardAssert(strlen($payload->getBody()) == $response_lengths[$i], |
|
|
|
|
hardAssert(strlen($payload->getBody()) === $response_lengths[$i], |
|
|
|
|
'Payload ' . $i . ' had the wrong length'); |
|
|
|
|
} |
|
|
|
|
$call->writesDone(); |
|
|
|
|
hardAssert($call->read() == null, 'Server returned too many responses'); |
|
|
|
|
hardAssert($call->getStatus()->code == Grpc\STATUS_OK, |
|
|
|
|
hardAssert($call->read() === null, 'Server returned too many responses'); |
|
|
|
|
hardAssert($call->getStatus()->code === Grpc\STATUS_OK, |
|
|
|
|
'Call did not complete successfully'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|