diff options
author | Stanley Cheung <stanleycheung@google.com> | 2015-12-10 15:52:20 -0800 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2015-12-10 15:52:20 -0800 |
commit | 42fb70699b9e97c73ad91ad6c78b4517548a5cf8 (patch) | |
tree | 5d2c6bcd926b5d5f8fb7b350880bd993e8e9d919 /src/php/tests/unit_tests/CallCredentialsTest.php | |
parent | 0149cb19f799de61b79bbca25a5e9fdb24b73b25 (diff) |
add more unit test
Diffstat (limited to 'src/php/tests/unit_tests/CallCredentialsTest.php')
-rw-r--r-- | src/php/tests/unit_tests/CallCredentialsTest.php | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/php/tests/unit_tests/CallCredentialsTest.php b/src/php/tests/unit_tests/CallCredentialsTest.php index 6f91b5ed96..aac21d4c49 100644 --- a/src/php/tests/unit_tests/CallCredentialsTest.php +++ b/src/php/tests/unit_tests/CallCredentialsTest.php @@ -81,7 +81,7 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase $deadline = Grpc\Timeval::infFuture(); $status_text = 'xyz'; $call = new Grpc\Call($this->channel, - '/abc/dummy_method/', + '/abc/dummy_method', $deadline, $this->host_override); @@ -92,5 +92,45 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase $this->assertTrue($event->send_metadata); $this->assertTrue($event->send_close); + + $event = $this->server->requestCall(); + + $this->assertTrue(is_array($event->metadata)); + $metadata = $event->metadata; + $this->assertTrue(array_key_exists('k1', $metadata)); + $this->assertTrue(array_key_exists('k2', $metadata)); + $this->assertSame($metadata['k1'], ['v1']); + $this->assertSame($metadata['k2'], ['v2']); + + $this->assertSame('/abc/dummy_method', $event->method); + $server_call = $event->call; + + $event = $server_call->startBatch([ + Grpc\OP_SEND_INITIAL_METADATA => [], + Grpc\OP_SEND_STATUS_FROM_SERVER => [ + 'metadata' => [], + 'code' => Grpc\STATUS_OK, + 'details' => $status_text, + ], + Grpc\OP_RECV_CLOSE_ON_SERVER => true, + ]); + + $this->assertTrue($event->send_metadata); + $this->assertTrue($event->send_status); + $this->assertFalse($event->cancelled); + + $event = $call->startBatch([ + Grpc\OP_RECV_INITIAL_METADATA => true, + Grpc\OP_RECV_STATUS_ON_CLIENT => true, + ]); + + $this->assertSame([], $event->metadata); + $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); } } |