aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/php/tests')
-rwxr-xr-xsrc/php/tests/generated_code/GeneratedCodeTest.php70
-rwxr-xr-xsrc/php/tests/generated_code/math.php479
-rwxr-xr-xsrc/php/tests/interop/empty.php26
-rwxr-xr-xsrc/php/tests/interop/interop_client.php191
-rwxr-xr-xsrc/php/tests/interop/message_set.php26
-rwxr-xr-xsrc/php/tests/interop/messages.php1011
-rwxr-xr-xsrc/php/tests/interop/test.php52
-rwxr-xr-xsrc/php/tests/unit_tests/CallTest.php48
-rwxr-xr-xsrc/php/tests/unit_tests/CompletionQueueTest.php14
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php185
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php196
-rwxr-xr-xsrc/php/tests/unit_tests/TimevalTest.php32
12 files changed, 2330 insertions, 0 deletions
diff --git a/src/php/tests/generated_code/GeneratedCodeTest.php b/src/php/tests/generated_code/GeneratedCodeTest.php
new file mode 100755
index 0000000000..d8d726e21a
--- /dev/null
+++ b/src/php/tests/generated_code/GeneratedCodeTest.php
@@ -0,0 +1,70 @@
+<?php
+require __DIR__ . '/../../lib/Grpc/ActiveCall.php';
+require __DIR__ . '/../../lib/Grpc/SurfaceActiveCall.php';
+require __DIR__ . '/../../lib/Grpc/BaseStub.php';
+require 'DrSlump/Protobuf.php';
+\DrSlump\Protobuf::autoload();
+require 'math.php';
+class GeneratedCodeTest extends PHPUnit_Framework_TestCase {
+ /* These tests require that a server exporting the math service must be
+ * running on $GRPC_TEST_HOST */
+ protected static $client;
+ protected static $timeout;
+ public static function setUpBeforeClass() {
+ self::$client = new math\MathClient(getenv('GRPC_TEST_HOST'));
+ }
+
+ public function testSimpleRequest() {
+ $div_arg = new math\DivArgs();
+ $div_arg->setDividend(7);
+ $div_arg->setDivisor(4);
+ list($response, $status) = self::$client->Div($div_arg)->wait();
+ $this->assertEquals(1, $response->getQuotient());
+ $this->assertEquals(3, $response->getRemainder());
+ $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ }
+
+ public function testServerStreaming() {
+ $fib_arg = new math\FibArgs();
+ $fib_arg->setLimit(7);
+ $call = self::$client->Fib($fib_arg);
+ $result_array = iterator_to_array($call->responses());
+ $extract_num = function($num){
+ return $num->getNum();
+ };
+ $values = array_map($extract_num, $result_array);
+ $this->assertEquals([1, 1, 2, 3, 5, 8, 13], $values);
+ $status = $call->getStatus();
+ $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ }
+
+ public function testClientStreaming() {
+ $num_iter = function() {
+ for ($i = 0; $i < 7; $i++) {
+ $num = new math\Num();
+ $num->setNum($i);
+ yield $num;
+ }
+ };
+ $call = self::$client->Sum($num_iter());
+ list($response, $status) = $call->wait();
+ $this->assertEquals(21, $response->getNum());
+ $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ }
+
+ public function testBidiStreaming() {
+ $call = self::$client->DivMany();
+ for ($i = 0; $i < 7; $i++) {
+ $div_arg = new math\DivArgs();
+ $div_arg->setDividend(2 * $i + 1);
+ $div_arg->setDivisor(2);
+ $call->write($div_arg);
+ $response = $call->read();
+ $this->assertEquals($i, $response->getQuotient());
+ $this->assertEquals(1, $response->getRemainder());
+ }
+ $call->writesDone();
+ $status = $call->getStatus();
+ $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ }
+} \ No newline at end of file
diff --git a/src/php/tests/generated_code/math.php b/src/php/tests/generated_code/math.php
new file mode 100755
index 0000000000..d50f94e11c
--- /dev/null
+++ b/src/php/tests/generated_code/math.php
@@ -0,0 +1,479 @@
+<?php
+// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
+// Source: math.proto
+// Date: 2014-11-14 00:00:41
+
+namespace math {
+
+ class DivArgs extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $dividend = null;
+
+ /** @var int */
+ public $divisor = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'math.DivArgs');
+
+ // REQUIRED INT64 dividend = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "dividend";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ // REQUIRED INT64 divisor = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "divisor";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <dividend> has a value
+ *
+ * @return boolean
+ */
+ public function hasDividend(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <dividend> value
+ *
+ * @return \math\DivArgs
+ */
+ public function clearDividend(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <dividend> value
+ *
+ * @return int
+ */
+ public function getDividend(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <dividend> value
+ *
+ * @param int $value
+ * @return \math\DivArgs
+ */
+ public function setDividend( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <divisor> has a value
+ *
+ * @return boolean
+ */
+ public function hasDivisor(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <divisor> value
+ *
+ * @return \math\DivArgs
+ */
+ public function clearDivisor(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <divisor> value
+ *
+ * @return int
+ */
+ public function getDivisor(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <divisor> value
+ *
+ * @param int $value
+ * @return \math\DivArgs
+ */
+ public function setDivisor( $value){
+ return $this->_set(2, $value);
+ }
+ }
+}
+
+namespace math {
+
+ class DivReply extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $quotient = null;
+
+ /** @var int */
+ public $remainder = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'math.DivReply');
+
+ // REQUIRED INT64 quotient = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "quotient";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ // REQUIRED INT64 remainder = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "remainder";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <quotient> has a value
+ *
+ * @return boolean
+ */
+ public function hasQuotient(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <quotient> value
+ *
+ * @return \math\DivReply
+ */
+ public function clearQuotient(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <quotient> value
+ *
+ * @return int
+ */
+ public function getQuotient(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <quotient> value
+ *
+ * @param int $value
+ * @return \math\DivReply
+ */
+ public function setQuotient( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <remainder> has a value
+ *
+ * @return boolean
+ */
+ public function hasRemainder(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <remainder> value
+ *
+ * @return \math\DivReply
+ */
+ public function clearRemainder(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <remainder> value
+ *
+ * @return int
+ */
+ public function getRemainder(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <remainder> value
+ *
+ * @param int $value
+ * @return \math\DivReply
+ */
+ public function setRemainder( $value){
+ return $this->_set(2, $value);
+ }
+ }
+}
+
+namespace math {
+
+ class FibArgs extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $limit = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'math.FibArgs');
+
+ // OPTIONAL INT64 limit = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "limit";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <limit> has a value
+ *
+ * @return boolean
+ */
+ public function hasLimit(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <limit> value
+ *
+ * @return \math\FibArgs
+ */
+ public function clearLimit(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <limit> value
+ *
+ * @return int
+ */
+ public function getLimit(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <limit> value
+ *
+ * @param int $value
+ * @return \math\FibArgs
+ */
+ public function setLimit( $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace math {
+
+ class Num extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $num = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'math.Num');
+
+ // REQUIRED INT64 num = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "num";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <num> has a value
+ *
+ * @return boolean
+ */
+ public function hasNum(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <num> value
+ *
+ * @return \math\Num
+ */
+ public function clearNum(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <num> value
+ *
+ * @return int
+ */
+ public function getNum(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <num> value
+ *
+ * @param int $value
+ * @return \math\Num
+ */
+ public function setNum( $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace math {
+
+ class FibReply extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $count = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'math.FibReply');
+
+ // REQUIRED INT64 count = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "count";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_REQUIRED;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <count> has a value
+ *
+ * @return boolean
+ */
+ public function hasCount(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <count> value
+ *
+ * @return \math\FibReply
+ */
+ public function clearCount(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <count> value
+ *
+ * @return int
+ */
+ public function getCount(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <count> value
+ *
+ * @param int $value
+ * @return \math\FibReply
+ */
+ public function setCount( $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace math {
+
+ class MathClient extends \Grpc\BaseStub {
+ /**
+ * @param math\DivArgs $input
+ * @return math\DivReply
+ */
+ public function Div(\math\DivArgs $argument, $metadata = array()) {
+ return $this->_simpleRequest('/Math/Div', $argument, '\math\DivReply::deserialize', $metadata);
+ }
+ /**
+ * @param math\DivArgs $input
+ * @return math\DivReply
+ */
+ public function DivMany($metadata = array()) {
+ return $this->_bidiRequest('/Math/DivMany', '\math\DivReply::deserialize', $metadata);
+ }
+ /**
+ * @param math\FibArgs $input
+ * @return math\Num
+ */
+ public function Fib($argument, $metadata = array()) {
+ return $this->_serverStreamRequest('/Math/Fib', $argument, '\math\Num::deserialize', $metadata);
+ }
+ /**
+ * @param math\Num $input
+ * @return math\Num
+ */
+ public function Sum($arguments, $metadata = array()) {
+ return $this->_clientStreamRequest('/Math/Sum', $arguments, '\math\Num::deserialize', $metadata);
+ }
+ }
+}
diff --git a/src/php/tests/interop/empty.php b/src/php/tests/interop/empty.php
new file mode 100755
index 0000000000..0107f2530b
--- /dev/null
+++ b/src/php/tests/interop/empty.php
@@ -0,0 +1,26 @@
+<?php
+// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
+// Source: net/proto2/proto/empty.proto
+// Date: 2014-12-03 22:02:20
+
+namespace proto2 {
+
+ class EmptyMessage extends \DrSlump\Protobuf\Message {
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'proto2.EmptyMessage');
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+ }
+}
+
diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php
new file mode 100755
index 0000000000..9810c86272
--- /dev/null
+++ b/src/php/tests/interop/interop_client.php
@@ -0,0 +1,191 @@
+<?php
+require __DIR__ . '/../../lib/Grpc/ActiveCall.php';
+require __DIR__ . '/../../lib/Grpc/SurfaceActiveCall.php';
+require __DIR__ . '/../../lib/Grpc/BaseStub.php';
+require 'DrSlump/Protobuf.php';
+\DrSlump\Protobuf::autoload();
+require 'empty.php';
+require 'message_set.php';
+require 'messages.php';
+require 'test.php';
+/**
+ * Assertion function that always exits with an error code if the assertion is
+ * falsy
+ * @param $value Assertion value. Should be true.
+ * @param $error_message Message to display if the assertion is false
+ */
+function hardAssert($value, $error_message) {
+ if(!$value) {
+ echo $error_message . "\n";
+ exit(1);
+ }
+}
+
+/**
+ * Run the empty_unary test.
+ * Currently not tested against any server as of 2014-12-04
+ * @param $stub Stub object that has service methods
+ */
+function emptyUnary($stub) {
+ list($result, $status) = $stub->EmptyCall(new proto2\EmptyMessage())->wait();
+ hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result != null, 'Call completed with a null response');
+}
+
+/**
+ * Run the large_unary test.
+ * Passes when run against the C++ server as of 2014-12-04
+ * Not tested against any other server as of 2014-12-04
+ * @param $stub Stub object that has service methods
+ */
+function largeUnary($stub) {
+ $request_len = 271828;
+ $response_len = 314159;
+
+ $request = new grpc\testing\SimpleRequest();
+ $request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
+ $request->setResponseSize($response_len);
+ $payload = new grpc\testing\Payload();
+ $payload->setType(grpc\testing\PayloadType::COMPRESSABLE);
+ $payload->setBody(str_repeat("\0", $request_len));
+ $request->setPayload($payload);
+
+ list($result, $status) = $stub->UnaryCall($request)->wait();
+ hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result != null, 'Call returned a null response');
+ $payload = $result->getPayload();
+ hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ 'Payload had the wrong type');
+ hardAssert(strlen($payload->getBody()) == $response_len,
+ 'Payload had the wrong length');
+ hardAssert($payload->getBody() == str_repeat("\0", $response_len),
+ 'Payload had the wrong content');
+}
+
+/**
+ * Run the client_streaming test.
+ * Not tested against any server as of 2014-12-04.
+ * @param $stub Stub object that has service methods
+ */
+function clientStreaming($stub) {
+ $request_lengths = array(27182, 8, 1828, 45904);
+
+ $requests = array_map(
+ function($length) {
+ $request = new grpc\testing\StreamingInputCallRequest();
+ $payload = new grpc\testing\Payload();
+ $payload->setBody(str_repeat("\0", $length));
+ $request->setPayload($payload);
+ return $request;
+ }, $request_lengths);
+
+ list($result, $status) = $stub->StreamingInputCall($requests)->wait();
+ hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result->getAggregatedPayloadSize() == 74922,
+ 'aggregated_payload_size was incorrect');
+}
+
+/**
+ * Run the server_streaming test.
+ * Not tested against any server as of 2014-12-04.
+ * @param $stub Stub object that has service methods.
+ */
+function serverStreaming($stub) {
+ $sizes = array(31415, 9, 2653, 58979);
+
+ $request = new grpc\testing\StreamingOutputCallRequest();
+ $request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
+ foreach($sizes as $size) {
+ $response_parameters = new grpc\testing\ResponseParameters();
+ $response_parameters->setSize($size);
+ $request->addResponseParameters($response_parameters);
+ }
+
+ $call = $stub->StreamingOutputCall($request);
+ hardAssert($call->getStatus()->code == Grpc\STATUS_OK,
+ 'Call did not complete successfully');
+ $i = 0;
+ foreach($call->responses() as $value) {
+ hardAssert($i < 4, 'Too many responses');
+ $payload = $value->getPayload();
+ hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ 'Payload ' . $i . ' had the wrong type');
+ hardAssert(strlen($payload->getBody()) == $sizes[$i],
+ 'Response ' . $i . ' had the wrong length');
+ }
+}
+
+/**
+ * Run the ping_pong test.
+ * Not tested against any server as of 2014-12-04.
+ * @param $stub Stub object that has service methods.
+ */
+function pingPong($stub) {
+ $request_lengths = array(27182, 8, 1828, 45904);
+ $response_lengths = array(31415, 9, 2653, 58979);
+
+ $call = $stub->FullDuplexCall();
+ for($i = 0; $i < 4; $i++) {
+ $request = new grpc\testing\StreamingOutputCallRequest();
+ $request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
+ $response_parameters = new grpc\testing\ResponseParameters();
+ $response_parameters->setSize($response_lengths[$i]);
+ $request->addResponseParameters($response_parameters);
+ $payload = new grpc\testing\Payload();
+ $payload->setBody(str_repeat("\0", $request_lengths[$i]));
+ $request->setPayload($payload);
+
+ $call->write($request);
+ $response = $call->read();
+
+ hardAssert($response != null, 'Server returned too few responses');
+ $payload = $response->getPayload();
+ hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ 'Payload ' . $i . ' had the wrong type');
+ hardAssert(strlen($payload->getBody()) == $response_lengths[$i],
+ 'Payload ' . $i . ' had the wrong length');
+ }
+ $call->writesDone();
+ hardAssert($call->read() == null, 'Server returned too many responses');
+ hardAssert($call->getStatus()->code == Grpc\STATUS_OK,
+ 'Call did not complete successfully');
+}
+
+$args = getopt('', array('server_host:', 'server_port:', 'test_case:'));
+if (!array_key_exists('server_host', $args) ||
+ !array_key_exists('server_port', $args) ||
+ !array_key_exists('test_case', $args)) {
+ throw new Exception('Missing argument');
+}
+
+$server_address = $args['server_host'] . ':' . $args['server_port'];
+
+$credentials = Grpc\Credentials::createSsl(
+ file_get_contents(dirname(__FILE__) . '/../data/ca.pem'));
+$stub = new grpc\testing\TestServiceClient(
+ $server_address,
+ [
+ 'grpc.ssl_target_name_override' => 'foo.test.google.com',
+ 'credentials' => $credentials
+ ]);
+
+echo "Connecting to $server_address\n";
+echo "Running test case $args[test_case]\n";
+
+switch($args['test_case']) {
+ case 'empty_unary':
+ emptyUnary($stub);
+ break;
+ case 'large_unary':
+ largeUnary($stub);
+ break;
+ case 'client_streaming':
+ clientStreaming($stub);
+ break;
+ case 'server_streaming':
+ serverStreaming($stub);
+ break;
+ case 'ping_pong':
+ pingPong($stub);
+ break;
+} \ No newline at end of file
diff --git a/src/php/tests/interop/message_set.php b/src/php/tests/interop/message_set.php
new file mode 100755
index 0000000000..c35c6d74b2
--- /dev/null
+++ b/src/php/tests/interop/message_set.php
@@ -0,0 +1,26 @@
+<?php
+// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
+// Source: net/proto2/bridge/proto/message_set.proto
+// Date: 2014-12-03 22:02:20
+
+namespace proto2\bridge {
+
+ class MessageSet extends \DrSlump\Protobuf\Message {
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'proto2.bridge.MessageSet');
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+ }
+}
+
diff --git a/src/php/tests/interop/messages.php b/src/php/tests/interop/messages.php
new file mode 100755
index 0000000000..beaec7c0d8
--- /dev/null
+++ b/src/php/tests/interop/messages.php
@@ -0,0 +1,1011 @@
+<?php
+// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
+// Source: third_party/stubby/testing/proto/messages.proto
+// Date: 2014-12-03 22:02:20
+
+namespace grpc\testing {
+
+ class PayloadType extends \DrSlump\Protobuf\Enum {
+ const COMPRESSABLE = 0;
+ const UNCOMPRESSABLE = 1;
+ const RANDOM = 2;
+ }
+}
+namespace grpc\testing {
+
+ class Payload extends \DrSlump\Protobuf\Message {
+
+ /** @var int - \grpc\testing\PayloadType */
+ public $type = null;
+
+ /** @var string */
+ public $body = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.Payload');
+
+ // OPTIONAL ENUM type = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "type";
+ $f->type = \DrSlump\Protobuf::TYPE_ENUM;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\PayloadType';
+ $descriptor->addField($f);
+
+ // OPTIONAL BYTES body = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "body";
+ $f->type = \DrSlump\Protobuf::TYPE_BYTES;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <type> has a value
+ *
+ * @return boolean
+ */
+ public function hasType(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <type> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function clearType(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <type> value
+ *
+ * @return int - \grpc\testing\PayloadType
+ */
+ public function getType(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <type> value
+ *
+ * @param int - \grpc\testing\PayloadType $value
+ * @return \grpc\testing\Payload
+ */
+ public function setType( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <body> has a value
+ *
+ * @return boolean
+ */
+ public function hasBody(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <body> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function clearBody(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <body> value
+ *
+ * @return string
+ */
+ public function getBody(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <body> value
+ *
+ * @param string $value
+ * @return \grpc\testing\Payload
+ */
+ public function setBody( $value){
+ return $this->_set(2, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class SimpleRequest extends \DrSlump\Protobuf\Message {
+
+ /** @var int - \grpc\testing\PayloadType */
+ public $response_type = null;
+
+ /** @var int */
+ public $response_size = null;
+
+ /** @var \grpc\testing\Payload */
+ public $payload = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.SimpleRequest');
+
+ // OPTIONAL ENUM response_type = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "response_type";
+ $f->type = \DrSlump\Protobuf::TYPE_ENUM;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\PayloadType';
+ $descriptor->addField($f);
+
+ // OPTIONAL INT32 response_size = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "response_size";
+ $f->type = \DrSlump\Protobuf::TYPE_INT32;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ // OPTIONAL MESSAGE payload = 3
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 3;
+ $f->name = "payload";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\Payload';
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <response_type> has a value
+ *
+ * @return boolean
+ */
+ public function hasResponseType(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <response_type> value
+ *
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function clearResponseType(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <response_type> value
+ *
+ * @return int - \grpc\testing\PayloadType
+ */
+ public function getResponseType(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <response_type> value
+ *
+ * @param int - \grpc\testing\PayloadType $value
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function setResponseType( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <response_size> has a value
+ *
+ * @return boolean
+ */
+ public function hasResponseSize(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <response_size> value
+ *
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function clearResponseSize(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <response_size> value
+ *
+ * @return int
+ */
+ public function getResponseSize(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <response_size> value
+ *
+ * @param int $value
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function setResponseSize( $value){
+ return $this->_set(2, $value);
+ }
+
+ /**
+ * Check if <payload> has a value
+ *
+ * @return boolean
+ */
+ public function hasPayload(){
+ return $this->_has(3);
+ }
+
+ /**
+ * Clear <payload> value
+ *
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function clearPayload(){
+ return $this->_clear(3);
+ }
+
+ /**
+ * Get <payload> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function getPayload(){
+ return $this->_get(3);
+ }
+
+ /**
+ * Set <payload> value
+ *
+ * @param \grpc\testing\Payload $value
+ * @return \grpc\testing\SimpleRequest
+ */
+ public function setPayload(\grpc\testing\Payload $value){
+ return $this->_set(3, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class SimpleResponse extends \DrSlump\Protobuf\Message {
+
+ /** @var \grpc\testing\Payload */
+ public $payload = null;
+
+ /** @var int */
+ public $effective_gaia_user_id = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.SimpleResponse');
+
+ // OPTIONAL MESSAGE payload = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "payload";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\Payload';
+ $descriptor->addField($f);
+
+ // OPTIONAL INT64 effective_gaia_user_id = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "effective_gaia_user_id";
+ $f->type = \DrSlump\Protobuf::TYPE_INT64;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <payload> has a value
+ *
+ * @return boolean
+ */
+ public function hasPayload(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <payload> value
+ *
+ * @return \grpc\testing\SimpleResponse
+ */
+ public function clearPayload(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <payload> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function getPayload(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <payload> value
+ *
+ * @param \grpc\testing\Payload $value
+ * @return \grpc\testing\SimpleResponse
+ */
+ public function setPayload(\grpc\testing\Payload $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <effective_gaia_user_id> has a value
+ *
+ * @return boolean
+ */
+ public function hasEffectiveGaiaUserId(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <effective_gaia_user_id> value
+ *
+ * @return \grpc\testing\SimpleResponse
+ */
+ public function clearEffectiveGaiaUserId(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <effective_gaia_user_id> value
+ *
+ * @return int
+ */
+ public function getEffectiveGaiaUserId(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <effective_gaia_user_id> value
+ *
+ * @param int $value
+ * @return \grpc\testing\SimpleResponse
+ */
+ public function setEffectiveGaiaUserId( $value){
+ return $this->_set(2, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class SimpleContext extends \DrSlump\Protobuf\Message {
+
+ /** @var string */
+ public $value = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.SimpleContext');
+
+ // OPTIONAL STRING value = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "value";
+ $f->type = \DrSlump\Protobuf::TYPE_STRING;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <value> has a value
+ *
+ * @return boolean
+ */
+ public function hasValue(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <value> value
+ *
+ * @return \grpc\testing\SimpleContext
+ */
+ public function clearValue(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <value> value
+ *
+ * @return string
+ */
+ public function getValue(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <value> value
+ *
+ * @param string $value
+ * @return \grpc\testing\SimpleContext
+ */
+ public function setValue( $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class StreamingInputCallRequest extends \DrSlump\Protobuf\Message {
+
+ /** @var \grpc\testing\Payload */
+ public $payload = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.StreamingInputCallRequest');
+
+ // OPTIONAL MESSAGE payload = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "payload";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\Payload';
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <payload> has a value
+ *
+ * @return boolean
+ */
+ public function hasPayload(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <payload> value
+ *
+ * @return \grpc\testing\StreamingInputCallRequest
+ */
+ public function clearPayload(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <payload> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function getPayload(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <payload> value
+ *
+ * @param \grpc\testing\Payload $value
+ * @return \grpc\testing\StreamingInputCallRequest
+ */
+ public function setPayload(\grpc\testing\Payload $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class StreamingInputCallResponse extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $aggregated_payload_size = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.StreamingInputCallResponse');
+
+ // OPTIONAL INT32 aggregated_payload_size = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "aggregated_payload_size";
+ $f->type = \DrSlump\Protobuf::TYPE_INT32;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <aggregated_payload_size> has a value
+ *
+ * @return boolean
+ */
+ public function hasAggregatedPayloadSize(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <aggregated_payload_size> value
+ *
+ * @return \grpc\testing\StreamingInputCallResponse
+ */
+ public function clearAggregatedPayloadSize(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <aggregated_payload_size> value
+ *
+ * @return int
+ */
+ public function getAggregatedPayloadSize(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <aggregated_payload_size> value
+ *
+ * @param int $value
+ * @return \grpc\testing\StreamingInputCallResponse
+ */
+ public function setAggregatedPayloadSize( $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class ResponseParameters extends \DrSlump\Protobuf\Message {
+
+ /** @var int */
+ public $size = null;
+
+ /** @var int */
+ public $interval_us = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.ResponseParameters');
+
+ // OPTIONAL INT32 size = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "size";
+ $f->type = \DrSlump\Protobuf::TYPE_INT32;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ // OPTIONAL INT32 interval_us = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "interval_us";
+ $f->type = \DrSlump\Protobuf::TYPE_INT32;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <size> has a value
+ *
+ * @return boolean
+ */
+ public function hasSize(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <size> value
+ *
+ * @return \grpc\testing\ResponseParameters
+ */
+ public function clearSize(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <size> value
+ *
+ * @return int
+ */
+ public function getSize(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <size> value
+ *
+ * @param int $value
+ * @return \grpc\testing\ResponseParameters
+ */
+ public function setSize( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <interval_us> has a value
+ *
+ * @return boolean
+ */
+ public function hasIntervalUs(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <interval_us> value
+ *
+ * @return \grpc\testing\ResponseParameters
+ */
+ public function clearIntervalUs(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <interval_us> value
+ *
+ * @return int
+ */
+ public function getIntervalUs(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Set <interval_us> value
+ *
+ * @param int $value
+ * @return \grpc\testing\ResponseParameters
+ */
+ public function setIntervalUs( $value){
+ return $this->_set(2, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class StreamingOutputCallRequest extends \DrSlump\Protobuf\Message {
+
+ /** @var int - \grpc\testing\PayloadType */
+ public $response_type = null;
+
+ /** @var \grpc\testing\ResponseParameters[] */
+ public $response_parameters = array();
+
+ /** @var \grpc\testing\Payload */
+ public $payload = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.StreamingOutputCallRequest');
+
+ // OPTIONAL ENUM response_type = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "response_type";
+ $f->type = \DrSlump\Protobuf::TYPE_ENUM;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\PayloadType';
+ $descriptor->addField($f);
+
+ // REPEATED MESSAGE response_parameters = 2
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 2;
+ $f->name = "response_parameters";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_REPEATED;
+ $f->reference = '\grpc\testing\ResponseParameters';
+ $descriptor->addField($f);
+
+ // OPTIONAL MESSAGE payload = 3
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 3;
+ $f->name = "payload";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\Payload';
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <response_type> has a value
+ *
+ * @return boolean
+ */
+ public function hasResponseType(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <response_type> value
+ *
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function clearResponseType(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <response_type> value
+ *
+ * @return int - \grpc\testing\PayloadType
+ */
+ public function getResponseType(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <response_type> value
+ *
+ * @param int - \grpc\testing\PayloadType $value
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function setResponseType( $value){
+ return $this->_set(1, $value);
+ }
+
+ /**
+ * Check if <response_parameters> has a value
+ *
+ * @return boolean
+ */
+ public function hasResponseParameters(){
+ return $this->_has(2);
+ }
+
+ /**
+ * Clear <response_parameters> value
+ *
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function clearResponseParameters(){
+ return $this->_clear(2);
+ }
+
+ /**
+ * Get <response_parameters> value
+ *
+ * @param int $idx
+ * @return \grpc\testing\ResponseParameters
+ */
+ public function getResponseParameters($idx = NULL){
+ return $this->_get(2, $idx);
+ }
+
+ /**
+ * Set <response_parameters> value
+ *
+ * @param \grpc\testing\ResponseParameters $value
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function setResponseParameters(\grpc\testing\ResponseParameters $value, $idx = NULL){
+ return $this->_set(2, $value, $idx);
+ }
+
+ /**
+ * Get all elements of <response_parameters>
+ *
+ * @return \grpc\testing\ResponseParameters[]
+ */
+ public function getResponseParametersList(){
+ return $this->_get(2);
+ }
+
+ /**
+ * Add a new element to <response_parameters>
+ *
+ * @param \grpc\testing\ResponseParameters $value
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function addResponseParameters(\grpc\testing\ResponseParameters $value){
+ return $this->_add(2, $value);
+ }
+
+ /**
+ * Check if <payload> has a value
+ *
+ * @return boolean
+ */
+ public function hasPayload(){
+ return $this->_has(3);
+ }
+
+ /**
+ * Clear <payload> value
+ *
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function clearPayload(){
+ return $this->_clear(3);
+ }
+
+ /**
+ * Get <payload> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function getPayload(){
+ return $this->_get(3);
+ }
+
+ /**
+ * Set <payload> value
+ *
+ * @param \grpc\testing\Payload $value
+ * @return \grpc\testing\StreamingOutputCallRequest
+ */
+ public function setPayload(\grpc\testing\Payload $value){
+ return $this->_set(3, $value);
+ }
+ }
+}
+
+namespace grpc\testing {
+
+ class StreamingOutputCallResponse extends \DrSlump\Protobuf\Message {
+
+ /** @var \grpc\testing\Payload */
+ public $payload = null;
+
+
+ /** @var \Closure[] */
+ protected static $__extensions = array();
+
+ public static function descriptor()
+ {
+ $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'grpc.testing.StreamingOutputCallResponse');
+
+ // OPTIONAL MESSAGE payload = 1
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 1;
+ $f->name = "payload";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\Payload';
+ $descriptor->addField($f);
+
+ foreach (self::$__extensions as $cb) {
+ $descriptor->addField($cb(), true);
+ }
+
+ return $descriptor;
+ }
+
+ /**
+ * Check if <payload> has a value
+ *
+ * @return boolean
+ */
+ public function hasPayload(){
+ return $this->_has(1);
+ }
+
+ /**
+ * Clear <payload> value
+ *
+ * @return \grpc\testing\StreamingOutputCallResponse
+ */
+ public function clearPayload(){
+ return $this->_clear(1);
+ }
+
+ /**
+ * Get <payload> value
+ *
+ * @return \grpc\testing\Payload
+ */
+ public function getPayload(){
+ return $this->_get(1);
+ }
+
+ /**
+ * Set <payload> value
+ *
+ * @param \grpc\testing\Payload $value
+ * @return \grpc\testing\StreamingOutputCallResponse
+ */
+ public function setPayload(\grpc\testing\Payload $value){
+ return $this->_set(1, $value);
+ }
+ }
+}
+
+namespace {
+ \proto2\bridge\MessageSet::extension(function(){
+ // OPTIONAL MESSAGE grpc\testing\SimpleContext\message_set_extension = 71139615
+ $f = new \DrSlump\Protobuf\Field();
+ $f->number = 71139615;
+ $f->name = "grpc\testing\SimpleContext\message_set_extension";
+ $f->type = \DrSlump\Protobuf::TYPE_MESSAGE;
+ $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL;
+ $f->reference = '\grpc\testing\SimpleContext';
+ return $f;
+ });
+} \ No newline at end of file
diff --git a/src/php/tests/interop/test.php b/src/php/tests/interop/test.php
new file mode 100755
index 0000000000..fe6d0fb6c4
--- /dev/null
+++ b/src/php/tests/interop/test.php
@@ -0,0 +1,52 @@
+<?php
+// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin 1.0
+// Source: third_party/stubby/testing/proto/test.proto
+// Date: 2014-12-03 22:02:20
+
+namespace grpc\testing {
+
+ class TestServiceClient extends \Grpc\BaseStub {
+ /**
+ * @param proto2\EmptyMessage $input
+ * @return proto2\EmptyMessage
+ */
+ public function EmptyCall(\proto2\EmptyMessage $argument, $metadata = array()) {
+ return $this->_simpleRequest('/TestService/EmptyCall', $argument, '\proto2\EmptyMessage::deserialize', $metadata);
+ }
+ /**
+ * @param grpc\testing\SimpleRequest $input
+ * @return grpc\testing\SimpleResponse
+ */
+ public function UnaryCall(\grpc\testing\SimpleRequest $argument, $metadata = array()) {
+ return $this->_simpleRequest('/TestService/UnaryCall', $argument, '\grpc\testing\SimpleResponse::deserialize', $metadata);
+ }
+ /**
+ * @param grpc\testing\StreamingOutputCallRequest $input
+ * @return grpc\testing\StreamingOutputCallResponse
+ */
+ public function StreamingOutputCall($argument, $metadata = array()) {
+ return $this->_serverStreamRequest('/TestService/StreamingOutputCall', $argument, '\grpc\testing\StreamingOutputCallResponse::deserialize', $metadata);
+ }
+ /**
+ * @param grpc\testing\StreamingInputCallRequest $input
+ * @return grpc\testing\StreamingInputCallResponse
+ */
+ public function StreamingInputCall($arguments, $metadata = array()) {
+ return $this->_clientStreamRequest('/TestService/StreamingInputCall', $arguments, '\grpc\testing\StreamingInputCallResponse::deserialize', $metadata);
+ }
+ /**
+ * @param grpc\testing\StreamingOutputCallRequest $input
+ * @return grpc\testing\StreamingOutputCallResponse
+ */
+ public function FullDuplexCall($metadata = array()) {
+ return $this->_bidiRequest('/TestService/FullDuplexCall', '\grpc\testing\StreamingOutputCallResponse::deserialize', $metadata);
+ }
+ /**
+ * @param grpc\testing\StreamingOutputCallRequest $input
+ * @return grpc\testing\StreamingOutputCallResponse
+ */
+ public function HalfDuplexCall($metadata = array()) {
+ return $this->_bidiRequest('/TestService/HalfDuplexCall', '\grpc\testing\StreamingOutputCallResponse::deserialize', $metadata);
+ }
+ }
+}
diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php
new file mode 100755
index 0000000000..150b8c3860
--- /dev/null
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -0,0 +1,48 @@
+<?php
+class CallTest extends PHPUnit_Framework_TestCase{
+ static $server;
+
+ public static function setUpBeforeClass() {
+ $cq = new Grpc\CompletionQueue();
+ self::$server = new Grpc\Server($cq, []);
+ self::$server->add_http2_port('localhost:9001');
+ }
+
+ public function setUp() {
+ $this->channel = new Grpc\Channel('localhost:9001', []);
+ $this->call = new Grpc\Call($this->channel,
+ '/foo',
+ Grpc\Timeval::inf_future());
+ }
+
+ /* 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
+ tests */
+
+ public function testAddEmptyMetadata() {
+ $this->call->add_metadata([], 0);
+ /* Dummy assert: Checks that the previous call completed without error */
+ $this->assertTrue(true);
+ }
+
+ public function testAddSingleMetadata() {
+ $this->call->add_metadata(['key' => 'value'], 0);
+ /* Dummy assert: Checks that the previous call completed without error */
+ $this->assertTrue(true);
+ }
+
+ public function testAddMultiValueMetadata() {
+ $this->call->add_metadata(['key' => ['value1', 'value2']], 0);
+ /* Dummy assert: Checks that the previous call completed without error */
+ $this->assertTrue(true);
+ }
+
+ public function testAddSingleAndMultiValueMetadata() {
+ $this->call->add_metadata(
+ ['key1' => 'value1',
+ 'key2' => ['value2', 'value3']], 0);
+ /* Dummy assert: Checks that the previous call completed without error */
+ $this->assertTrue(true);
+ }
+}
diff --git a/src/php/tests/unit_tests/CompletionQueueTest.php b/src/php/tests/unit_tests/CompletionQueueTest.php
new file mode 100755
index 0000000000..f88cd63002
--- /dev/null
+++ b/src/php/tests/unit_tests/CompletionQueueTest.php
@@ -0,0 +1,14 @@
+<?php
+class CompletionQueueTest extends PHPUnit_Framework_TestCase{
+ public function testNextReturnsNullWithNoCall() {
+ $cq = new Grpc\CompletionQueue();
+ $event = $cq->next(Grpc\Timeval::zero());
+ $this->assertNull($event);
+ }
+
+ public function testPluckReturnsNullWithNoCall() {
+ $cq = new Grpc\CompletionQueue();
+ $event = $cq->pluck(0, Grpc\Timeval::zero());
+ $this->assertNull($event);
+ }
+} \ No newline at end of file
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
new file mode 100755
index 0000000000..a6e4a89ac0
--- /dev/null
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -0,0 +1,185 @@
+<?php
+class EndToEndTest extends PHPUnit_Framework_TestCase{
+ public function setUp() {
+ $this->client_queue = new Grpc\CompletionQueue();
+ $this->server_queue = new Grpc\CompletionQueue();
+ $this->server = new Grpc\Server($this->server_queue, []);
+ $this->server->add_http2_port('localhost:9000');
+ $this->channel = new Grpc\Channel('localhost:9000', []);
+ }
+
+ public function tearDown() {
+ unset($this->channel);
+ unset($this->server);
+ unset($this->client_queue);
+ unset($this->server_queue);
+ }
+
+ public function testSimpleRequestBody() {
+ $deadline = Grpc\Timeval::inf_future();
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+ $tag = 1;
+ $this->assertEquals(Grpc\CALL_OK,
+ $call->start_invoke($this->client_queue,
+ $tag,
+ $tag,
+ $tag));
+
+ $server_tag = 2;
+
+ // the client invocation was accepted
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->get_type());
+
+ $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // check that a server rpc new was received
+ $this->server->start();
+ $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->get_type());
+ $server_call = $event->get_call();
+ $this->assertNotNull($server_call);
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->accept($this->server_queue, $server_tag));
+
+ // the server sends the status
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write_status(Grpc\STATUS_OK,
+ $status_text,
+ $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the client gets CLIENT_METADATA_READ
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->get_type());
+
+ // the client gets FINISHED
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+ $this->assertEquals(Grpc\STATUS_OK, $status->code);
+ $this->assertEquals($status_text, $status->details);
+
+ // and the server gets FINISHED
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+
+ unset($call);
+ unset($server_call);
+ }
+
+ public function testClientServerFullRequestResponse() {
+ $deadline = Grpc\Timeval::inf_future();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+ $tag = 1;
+ $this->assertEquals(Grpc\CALL_OK,
+ $call->start_invoke($this->client_queue,
+ $tag,
+ $tag,
+ $tag));
+
+ $server_tag = 2;
+
+ // the client invocation was accepted
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->get_type());
+
+ // the client writes
+ $this->assertEquals(Grpc\CALL_OK, $call->start_write($req_text, $tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->get_type());
+
+ // check that a server rpc new was received
+ $this->server->start();
+ $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->get_type());
+ $server_call = $event->get_call();
+ $this->assertNotNull($server_call);
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->accept($this->server_queue, $server_tag));
+
+ // start the server read
+ $this->assertEquals(Grpc\CALL_OK, $server_call->start_read($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\READ, $event->get_type());
+ $this->assertEquals($req_text, $event->get_data());
+
+ // the server replies
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write($reply_text, $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->get_type());
+
+ // the client reads the metadata
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->get_type());
+
+ // the client reads the reply
+ $this->assertEquals(Grpc\CALL_OK, $call->start_read($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\READ, $event->get_type());
+ $this->assertEquals($reply_text, $event->get_data());
+
+ // the client sends writes done
+ $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the server sends the status
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write_status(GRPC\STATUS_OK,
+ $status_text,
+ $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the client gets FINISHED
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+ $this->assertEquals(Grpc\STATUS_OK, $status->code);
+ $this->assertEquals($status_text, $status->details);
+
+ // and the server gets FINISHED
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+
+ unset($call);
+ unset($server_call);
+ }
+} \ No newline at end of file
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
new file mode 100755
index 0000000000..d645c03e4c
--- /dev/null
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -0,0 +1,196 @@
+<?php
+class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
+ public function setUp() {
+ $this->client_queue = new Grpc\CompletionQueue();
+ $this->server_queue = new Grpc\CompletionQueue();
+ $credentials = Grpc\Credentials::createSsl(
+ file_get_contents(dirname(__FILE__) . '/../data/ca.pem'));
+ $server_credentials = Grpc\ServerCredentials::createSsl(
+ null,
+ file_get_contents(dirname(__FILE__) . '/../data/server1.key'),
+ file_get_contents(dirname(__FILE__) . '/../data/server1.pem'));
+ $this->server = new Grpc\Server($this->server_queue,
+ ['credentials' => $server_credentials]);
+ $this->server->add_secure_http2_port('localhost:9000');
+ $this->channel = new Grpc\Channel(
+ 'localhost:9000',
+ [
+ 'grpc.ssl_target_name_override' => 'foo.test.google.com',
+ 'credentials' => $credentials
+ ]);
+ }
+
+ public function tearDown() {
+ unset($this->channel);
+ unset($this->server);
+ unset($this->client_queue);
+ unset($this->server_queue);
+ }
+
+ public function testSimpleRequestBody() {
+ $this->server->start();
+ $deadline = Grpc\Timeval::inf_future();
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+ $tag = 1;
+ $this->assertEquals(Grpc\CALL_OK,
+ $call->start_invoke($this->client_queue,
+ $tag,
+ $tag,
+ $tag));
+ $server_tag = 2;
+
+ // the client invocation was accepted
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->get_type());
+
+ $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // check that a server rpc new was received
+ $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->get_type());
+ $server_call = $event->get_call();
+ $this->assertNotNull($server_call);
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->accept($this->server_queue, $server_tag));
+
+ // the server sends the status
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write_status(Grpc\STATUS_OK,
+ $status_text,
+ $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the client gets CLIENT_METADATA_READ
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->get_type());
+
+ // the client gets FINISHED
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+ $this->assertEquals(Grpc\STATUS_OK, $status->code);
+ $this->assertEquals($status_text, $status->details);
+
+ // and the server gets FINISHED
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+
+ unset($call);
+ unset($server_call);
+ }
+
+ public function testClientServerFullRequestResponse() {
+ $this->server->start();
+ $deadline = Grpc\Timeval::inf_future();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+ $tag = 1;
+ $this->assertEquals(Grpc\CALL_OK,
+ $call->start_invoke($this->client_queue,
+ $tag,
+ $tag,
+ $tag));
+
+ $server_tag = 2;
+
+ // the client invocation was accepted
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\INVOKE_ACCEPTED, $event->get_type());
+
+ // the client writes
+ $this->assertEquals(Grpc\CALL_OK, $call->start_write($req_text, $tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->get_type());
+
+ // check that a server rpc new was received
+ $this->assertEquals(Grpc\CALL_OK, $this->server->request_call($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->get_type());
+ $server_call = $event->get_call();
+ $this->assertNotNull($server_call);
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->accept($this->server_queue, $server_tag));
+
+ // start the server read
+ $this->assertEquals(Grpc\CALL_OK, $server_call->start_read($server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\READ, $event->get_type());
+ $this->assertEquals($req_text, $event->get_data());
+
+ // the server replies
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write($reply_text, $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->get_type());
+
+ // the client reads the metadata
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->get_type());
+
+ // the client reads the reply
+ $this->assertEquals(Grpc\CALL_OK, $call->start_read($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\READ, $event->get_type());
+ $this->assertEquals($reply_text, $event->get_data());
+
+ // the client sends writes done
+ $this->assertEquals(Grpc\CALL_OK, $call->writes_done($tag));
+ $event = $this->client_queue->next($deadline);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the server sends the status
+ $this->assertEquals(Grpc\CALL_OK,
+ $server_call->start_write_status(GRPC\STATUS_OK,
+ $status_text,
+ $server_tag));
+ $event = $this->server_queue->next($deadline);
+ $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->get_type());
+ $this->assertEquals(Grpc\OP_OK, $event->get_data());
+
+ // the client gets FINISHED
+ $event = $this->client_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+ $status = $event->get_data();
+ $this->assertEquals(Grpc\STATUS_OK, $status->code);
+ $this->assertEquals($status_text, $status->details);
+
+ // and the server gets FINISHED
+ $event = $this->server_queue->next($deadline);
+ $this->assertNotNull($event);
+ $this->assertEquals(Grpc\FINISHED, $event->get_type());
+
+ unset($call);
+ unset($server_call);
+ }
+} \ No newline at end of file
diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php
new file mode 100755
index 0000000000..6af9fba043
--- /dev/null
+++ b/src/php/tests/unit_tests/TimevalTest.php
@@ -0,0 +1,32 @@
+<?php
+class TimevalTest extends PHPUnit_Framework_TestCase{
+ public function testCompareSame() {
+ $zero = Grpc\Timeval::zero();
+ $this->assertEquals(0, Grpc\Timeval::compare($zero, $zero));
+ }
+
+ public function testPastIsLessThanZero() {
+ $zero = Grpc\Timeval::zero();
+ $past = Grpc\Timeval::inf_past();
+ $this->assertLessThan(0, Grpc\Timeval::compare($past, $zero));
+ $this->assertGreaterThan(0, Grpc\Timeval::compare($zero, $past));
+ }
+
+ public function testFutureIsGreaterThanZero() {
+ $zero = Grpc\Timeval::zero();
+ $future = Grpc\Timeval::inf_future();
+ $this->assertLessThan(0, Grpc\Timeval::compare($zero, $future));
+ $this->assertGreaterThan(0, Grpc\Timeval::compare($future, $zero));
+ }
+
+ /**
+ * @depends testFutureIsGreaterThanZero
+ */
+ public function testNowIsBetweenZeroAndFuture() {
+ $zero = Grpc\Timeval::zero();
+ $future = Grpc\Timeval::inf_future();
+ $now = Grpc\Timeval::now();
+ $this->assertLessThan(0, Grpc\Timeval::compare($zero, $now));
+ $this->assertLessThan(0, Grpc\Timeval::compare($now, $future));
+ }
+} \ No newline at end of file