| 
					
				 | 
			
			
				@@ -116,6 +116,53 @@ function performLargeUnary($stub, $fillUsername = false, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return $result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Run the client_compressed_unary test. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $stub Stub object that has service methods 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function clientCompressedUnary($stub) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $request_len = 271828; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $response_len = 314159; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $falseBoolValue = new Grpc\Testing\BoolValue(['value' => false]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $trueBoolValue = new Grpc\Testing\BoolValue(['value' => true]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 1. Probing for compression-checks support 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $payload = new Grpc\Testing\Payload([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'body' => str_repeat("\0", $request_len), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $request = new Grpc\Testing\SimpleRequest([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'payload' => $payload, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'response_size' => $response_len, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'expect_compressed' => $trueBoolValue, // lie 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    list($result, $status) = $stub->UnaryCall($request, [], [])->wait(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    hardAssert( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $status->code === GRPC\STATUS_INVALID_ARGUMENT, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'Received unexpected UnaryCall status code: ' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $status->code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 2. with/without compressed message 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    foreach ([true, false] as $compression) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $request->setExpectCompressed($compression ? $trueBoolValue : $falseBoolValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $metadata = $compression ? [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'grpc-internal-encoding-request' => ['gzip'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ] : []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        list($result, $status) = $stub->UnaryCall($request, $metadata, [])->wait(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        hardAssertIfStatusOk($status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        hardAssert($result !== null, 'Call returned a null response'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $payload = $result->getPayload(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        hardAssert( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            strlen($payload->getBody()) === $response_len, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'Payload had the wrong length' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        hardAssert( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $payload->getBody() === str_repeat("\0", $response_len), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'Payload had the wrong content' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * Run the service account credentials auth test. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -673,6 +720,9 @@ function interop_main($args, $stub = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         case 'per_rpc_creds': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             perRpcCreds($stub, $args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 'client_compressed_unary': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            clientCompressedUnary($stub); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             echo "Unsupported test case $test_case\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             exit(1); 
			 |