aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/tests/unit_tests/CallCredentialsTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/php/tests/unit_tests/CallCredentialsTest.php')
-rw-r--r--src/php/tests/unit_tests/CallCredentialsTest.php51
1 files changed, 44 insertions, 7 deletions
diff --git a/src/php/tests/unit_tests/CallCredentialsTest.php b/src/php/tests/unit_tests/CallCredentialsTest.php
index 0918412781..5fec06cd13 100644
--- a/src/php/tests/unit_tests/CallCredentialsTest.php
+++ b/src/php/tests/unit_tests/CallCredentialsTest.php
@@ -36,13 +36,13 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $credentials = Grpc\ChannelCredentials::createSsl(
+ $this->credentials = Grpc\ChannelCredentials::createSsl(
file_get_contents(dirname(__FILE__).'/../data/ca.pem'));
- $call_credentials = Grpc\CallCredentials::createFromPlugin(
- array($this, 'callbackFunc'));
- $credentials = Grpc\ChannelCredentials::createComposite(
- $credentials,
- $call_credentials
+ $this->call_credentials = Grpc\CallCredentials::createFromPlugin(
+ [$this, 'callbackFunc']);
+ $this->credentials = Grpc\ChannelCredentials::createComposite(
+ $this->credentials,
+ $this->call_credentials
);
$server_credentials = Grpc\ServerCredentials::createSsl(
null,
@@ -58,7 +58,7 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
[
'grpc.ssl_target_name_override' => $this->host_override,
'grpc.default_authority' => $this->host_override,
- 'credentials' => $credentials,
+ 'credentials' => $this->credentials,
]
);
}
@@ -134,4 +134,41 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
unset($call);
unset($server_call);
}
+
+ public function callbackFunc2($context)
+ {
+ return [];
+ }
+
+ public function testCreateComposite()
+ {
+ $call_credentials2 = Grpc\CallCredentials::createFromPlugin(
+ [$this, 'callbackFunc2']);
+ $call_credentials3 = Grpc\CallCredentials::createComposite(
+ $this->call_credentials,
+ $call_credentials2
+ );
+ $this->assertSame('Grpc\CallCredentials', get_class($call_credentials3));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCreateFromPluginInvalidParam()
+ {
+ $call_credentials = Grpc\CallCredentials::createFromPlugin(
+ 'callbackFunc'
+ );
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCreateCompositeInvalidParam()
+ {
+ $call_credentials3 = Grpc\CallCredentials::createComposite(
+ $this->call_credentials,
+ $this->credentials
+ );
+ }
}