|
|
@@ -12,7 +12,7 @@ use Uraus\Kku\Response;
|
|
|
* protobuf请求测试
|
|
|
*
|
|
|
*/
|
|
|
-abstract class ProtoJsonRequestTest extends \Tests\TestCase implements ProtoRequest
|
|
|
+abstract class ProtoJsonRequestTest extends \Tests\TestCase implements ProtoJsonRequest
|
|
|
{
|
|
|
|
|
|
protected Client $client;
|
|
|
@@ -47,21 +47,19 @@ abstract class ProtoJsonRequestTest extends \Tests\TestCase implements ProtoRequ
|
|
|
Log::info('准备 测试数据');
|
|
|
|
|
|
// 1. 准备 Protobuf 请求数据
|
|
|
- $requestData = $this->create_request_protobuf();
|
|
|
- $name = substr(get_class($requestData), 17);
|
|
|
- $requestDatabin = $requestData->serializeToString();
|
|
|
+ $requestJson = $this->requestProtobufJson();
|
|
|
Log::info('序列化请求数据完成', [
|
|
|
- 'data_length' => strlen($requestDatabin),
|
|
|
- 'request_data' => $requestData->serializeToJsonString()
|
|
|
+ 'data_length' => strlen($requestJson),
|
|
|
+ 'request_data' => $requestJson
|
|
|
]);
|
|
|
|
|
|
// 2. 发送真实的 HTTP 请求
|
|
|
Log::info('发送 HTTP 请求');
|
|
|
$response = $this->client->post('/gameapi', [
|
|
|
- 'body' => $requestDatabin,
|
|
|
+ 'body' => $requestJson,
|
|
|
'headers' => [
|
|
|
- 'Content-Type' => 'application/x-protobuf',
|
|
|
- 'Accept' => 'application/x-protobuf'
|
|
|
+ 'Content-Type' => 'application/json',
|
|
|
+ 'Accept' => 'application/json'
|
|
|
]
|
|
|
]);
|
|
|
|
|
|
@@ -80,7 +78,7 @@ abstract class ProtoJsonRequestTest extends \Tests\TestCase implements ProtoRequ
|
|
|
]);
|
|
|
|
|
|
$protoResponse = new Response();
|
|
|
- $protoResponse->mergeFromString($responseContent);
|
|
|
+ $protoResponse->mergeFromJsonString($responseContent);
|
|
|
|
|
|
Log::info('测试完成');
|
|
|
|