aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/tests/unit_tests
diff options
context:
space:
mode:
authorGravatar mlumish <mlumish@google.com>2015-01-02 13:34:14 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-01-05 17:43:09 -0800
commit8f91163795e5858fa31d05f25543139996b13b10 (patch)
tree9d55315c7528be61df56f82e36a2e93abd2beaaa /src/php/tests/unit_tests
parent34cd1f0eec5c01f6a8dba5723aac4a0ec302139b (diff)
Switched call errors to exceptions instead of return values
Change on 2015/01/02 by mlumish <mlumish@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83146107
Diffstat (limited to 'src/php/tests/unit_tests')
-rwxr-xr-xsrc/php/tests/unit_tests/CallTest.php19
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php14
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php14
3 files changed, 33 insertions, 14 deletions
diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php
index 150b8c3860..253052a038 100755
--- a/src/php/tests/unit_tests/CallTest.php
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -9,12 +9,31 @@ class CallTest extends PHPUnit_Framework_TestCase{
}
public function setUp() {
+ $this->cq = new Grpc\CompletionQueue();
$this->channel = new Grpc\Channel('localhost:9001', []);
$this->call = new Grpc\Call($this->channel,
'/foo',
Grpc\Timeval::inf_future());
}
+ /**
+ * @expectedException LogicException
+ * @expectedExceptionCode Grpc\CALL_ERROR_INVALID_FLAGS
+ * @expectedExceptionMessage start_invoke
+ */
+ public function testStartInvokeRejectsBadFlags() {
+ $this->call->start_invoke($this->cq, 0, 0, 0, 0xDEADBEEF);
+ }
+
+ /**
+ * @expectedException LogicException
+ * @expectedExceptionCode Grpc\CALL_ERROR_NOT_ON_CLIENT
+ * @expectedExceptionMessage server_accept
+ */
+ public function testServerAcceptFailsCorrectly() {
+ $this->call->server_accept($this->cq, 0);
+ }
+
/* These test methods with assertTrue(true) at the end just check that the
method calls completed without errors. PHPUnit warns for tests with no
asserts, and this avoids that warning without changing the meaning of the
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index e4433c8310..3818f9531c 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -37,7 +37,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertNotNull($event);
$this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
@@ -45,7 +45,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
// check that a server rpc new was received
$this->server->start();
- $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
@@ -116,14 +116,14 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->type);
// the client writes
- $this->assertEquals(Grpc\CALL_OK, $call->start_write($req_text, $tag));
+ $call->start_write($req_text, $tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
// check that a server rpc new was received
$this->server->start();
- $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
@@ -137,7 +137,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$server_call->server_end_initial_metadata());
// start the server read
- $this->assertEquals(Grpc\CALL_OK, $server_call->start_read($server_tag));
+ $server_call->start_read($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\READ, $event->type);
@@ -156,14 +156,14 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
// the client reads the reply
- $this->assertEquals(Grpc\CALL_OK, $call->start_read($tag));
+ $call->start_read($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\READ, $event->type);
$this->assertEquals($reply_text, $event->data);
// the client sends writes done
- $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
$this->assertEquals(Grpc\OP_OK, $event->data);
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
index 70fb31de1e..c562a821a4 100755
--- a/src/php/tests/unit_tests/SecureEndToEndTest.php
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -48,14 +48,14 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertNotNull($event);
$this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
$this->assertEquals(Grpc\OP_OK, $event->data);
// check that a server rpc new was received
- $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
@@ -126,13 +126,13 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->type);
// the client writes
- $this->assertEquals(Grpc\CALL_OK, $call->start_write($req_text, $tag));
+ $call->start_write($req_text, $tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
// check that a server rpc new was received
- $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
@@ -146,7 +146,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$server_call->server_end_initial_metadata());
// start the server read
- $this->assertEquals(Grpc\CALL_OK, $server_call->start_read($server_tag));
+ $server_call->start_read($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\READ, $event->type);
@@ -165,14 +165,14 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
// the client reads the reply
- $this->assertEquals(Grpc\CALL_OK, $call->start_read($tag));
+ $call->start_read($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
$this->assertEquals(Grpc\READ, $event->type);
$this->assertEquals($reply_text, $event->data);
// the client sends writes done
- $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
$this->assertEquals(Grpc\OP_OK, $event->data);