aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/tests/generated_code
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2016-02-12 10:11:05 -0800
committerGravatar Stanley Cheung <stanleycheung@google.com>2016-02-12 10:11:05 -0800
commit76e9ad416ea03131db94d53ffa0f75f1c8a25f4f (patch)
tree7bb9cb3743aa8865b7936093ad0b8a66660fd6e9 /src/php/tests/generated_code
parentbf53a74b3f626c38aa65dd01d2f3d321b53c1fbe (diff)
php: add unit test to bring coverage back up above 95%
Diffstat (limited to 'src/php/tests/generated_code')
-rw-r--r--src/php/tests/generated_code/AbstractGeneratedCodeTest.php45
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();