From c43b77b73838e110cb67b6a3250bd3dba0c14bf8 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 5 Jun 2019 21:40:17 -0700 Subject: [PATCH] Add tests for allowing dots in metadata keys --- .../AbstractGeneratedCodeTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index c050a26cbf5..f7b47359992 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -71,6 +71,33 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase $call = self::$client->Div($div_arg, [' ' => 'abc123']); } + public function testMetadata() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['somekey' => ['abc123']]); + } + + public function testMetadataKey() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['somekey_-1' => ['abc123']]); + } + + public function testMetadataKeyWithDot() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['someKEY._-1' => ['abc123']]); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testMetadataInvalidKey() + { + $div_arg = new Math\DivArgs(); + $call = self::$client->Div($div_arg, ['(somekey)' => ['abc123']]); + } + public function testGetCallMetadata() { $div_arg = new Math\DivArgs(); @@ -81,6 +108,8 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase public function testTimeout() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, [], ['timeout' => 1]); list($response, $status) = $call->wait(); $this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code);