diff options
Diffstat (limited to 'src/php/tests/generated_code/AbstractGeneratedCodeTest.php')
-rw-r--r-- | src/php/tests/generated_code/AbstractGeneratedCodeTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index 1fe81b9d54..75922d4cf7 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -106,6 +106,34 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code); } + public function testCallCredentialsCallback() + { + $div_arg = new math\DivArgs(); + $call = self::$client->Div($div_arg, array(), array( + 'call_credentials_callback' => function ($context) { + return array(); + }, + )); + $call->cancel(); + list($response, $status) = $call->wait(); + $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code); + } + + public function testCallCredentialsCallback2() + { + $div_arg = new math\DivArgs(); + $call = self::$client->Div($div_arg); + $call_credentials = Grpc\CallCredentials::createFromPlugin( + function ($context) { + return array(); + } + ); + $call->setCallCredentials($call_credentials); + $call->cancel(); + list($response, $status) = $call->wait(); + $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code); + } + /** * @expectedException InvalidArgumentException */ @@ -118,6 +146,23 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase $invalid_client->InvalidUnaryCall($div_arg); } + /** + * @expectedException Exception + */ + public function testMissingCredentials() + { + $invalid_client = new DummyInvalidClient('host', [ + ]); + } + + public function testPrimaryUserAgentString() + { + $invalid_client = new DummyInvalidClient('host', [ + 'credentials' => Grpc\ChannelCredentials::createInsecure(), + 'grpc.primary_user_agent' => 'testUserAgent', + ]); + } + public function testWriteFlags() { $div_arg = new math\DivArgs(); |