From f21eb2573b398a83dedf3d2123e1d8438106b492 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 30 Jan 2015 13:47:41 -0800 Subject: [PATCH] Fixed PHP interop tests --- src/php/lib/Grpc/ActiveCall.php | 6 +- src/php/lib/Grpc/BaseStub.php | 4 +- src/php/tests/interop/empty.php | 9 +- src/php/tests/interop/interop_client.php | 2 +- src/php/tests/interop/messages.php | 213 +++++++++++++++-------- src/php/tests/interop/test.php | 22 +-- 6 files changed, 159 insertions(+), 97 deletions(-) diff --git a/src/php/lib/Grpc/ActiveCall.php b/src/php/lib/Grpc/ActiveCall.php index 836a4b09e3b..e0ea43ab085 100755 --- a/src/php/lib/Grpc/ActiveCall.php +++ b/src/php/lib/Grpc/ActiveCall.php @@ -28,9 +28,9 @@ class ActiveCall { $this->flags = $flags; // Invoke the call. - $this->call->start_invoke($this->completion_queue, - CLIENT_METADATA_READ, - FINISHED, 0); + $this->call->invoke($this->completion_queue, + CLIENT_METADATA_READ, + FINISHED, 0); $metadata_event = $this->completion_queue->pluck(CLIENT_METADATA_READ, Timeval::inf_future()); $this->metadata = $metadata_event->data; diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index e1feb1206b7..e745ec3709f 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -10,8 +10,8 @@ class BaseStub { private $channel; - public function __construct($hostname) { - $this->channel = new Channel($hostname, []); + public function __construct($hostname, $opts) { + $this->channel = new Channel($hostname, $opts); } /** diff --git a/src/php/tests/interop/empty.php b/src/php/tests/interop/empty.php index 0107f2530b9..3e4968fcc3e 100755 --- a/src/php/tests/interop/empty.php +++ b/src/php/tests/interop/empty.php @@ -1,9 +1,9 @@ addField($cb(), true); @@ -23,4 +23,3 @@ namespace proto2 { } } } - diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 43da47fd531..c83750635bf 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -25,7 +25,7 @@ function hardAssert($value, $error_message) { * @param $stub Stub object that has service methods */ function emptyUnary($stub) { - list($result, $status) = $stub->EmptyCall(new proto2\EmptyMessage())->wait(); + list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); hardAssert($result != null, 'Call completed with a null response'); } diff --git a/src/php/tests/interop/messages.php b/src/php/tests/interop/messages.php index beaec7c0d87..bbdd296452e 100755 --- a/src/php/tests/interop/messages.php +++ b/src/php/tests/interop/messages.php @@ -1,7 +1,7 @@ reference = '\grpc\testing\Payload'; $descriptor->addField($f); + // OPTIONAL BOOL fill_username = 4 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 4; + $f->name = "fill_username"; + $f->type = \DrSlump\Protobuf::TYPE_BOOL; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); + + // OPTIONAL BOOL fill_oauth_scope = 5 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 5; + $f->name = "fill_oauth_scope"; + $f->type = \DrSlump\Protobuf::TYPE_BOOL; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); + foreach (self::$__extensions as $cb) { $descriptor->addField($cb(), true); } @@ -293,6 +315,80 @@ namespace grpc\testing { public function setPayload(\grpc\testing\Payload $value){ return $this->_set(3, $value); } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasFillUsername(){ + return $this->_has(4); + } + + /** + * Clear value + * + * @return \grpc\testing\SimpleRequest + */ + public function clearFillUsername(){ + return $this->_clear(4); + } + + /** + * Get value + * + * @return boolean + */ + public function getFillUsername(){ + return $this->_get(4); + } + + /** + * Set value + * + * @param boolean $value + * @return \grpc\testing\SimpleRequest + */ + public function setFillUsername( $value){ + return $this->_set(4, $value); + } + + /** + * Check if has a value + * + * @return boolean + */ + public function hasFillOauthScope(){ + return $this->_has(5); + } + + /** + * Clear value + * + * @return \grpc\testing\SimpleRequest + */ + public function clearFillOauthScope(){ + return $this->_clear(5); + } + + /** + * Get value + * + * @return boolean + */ + public function getFillOauthScope(){ + return $this->_get(5); + } + + /** + * Set value + * + * @param boolean $value + * @return \grpc\testing\SimpleRequest + */ + public function setFillOauthScope( $value){ + return $this->_set(5, $value); + } } } @@ -303,8 +399,11 @@ namespace grpc\testing { /** @var \grpc\testing\Payload */ public $payload = null; - /** @var int */ - public $effective_gaia_user_id = null; + /** @var string */ + public $username = null; + + /** @var string */ + public $oauth_scope = null; /** @var \Closure[] */ @@ -323,11 +422,19 @@ namespace grpc\testing { $f->reference = '\grpc\testing\Payload'; $descriptor->addField($f); - // OPTIONAL INT64 effective_gaia_user_id = 2 + // OPTIONAL STRING username = 2 $f = new \DrSlump\Protobuf\Field(); $f->number = 2; - $f->name = "effective_gaia_user_id"; - $f->type = \DrSlump\Protobuf::TYPE_INT64; + $f->name = "username"; + $f->type = \DrSlump\Protobuf::TYPE_STRING; + $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; + $descriptor->addField($f); + + // OPTIONAL STRING oauth_scope = 3 + $f = new \DrSlump\Protobuf\Field(); + $f->number = 3; + $f->name = "oauth_scope"; + $f->type = \DrSlump\Protobuf::TYPE_STRING; $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; $descriptor->addField($f); @@ -376,109 +483,77 @@ namespace grpc\testing { } /** - * Check if has a value + * Check if has a value * * @return boolean */ - public function hasEffectiveGaiaUserId(){ + public function hasUsername(){ return $this->_has(2); } /** - * Clear value + * Clear value * * @return \grpc\testing\SimpleResponse */ - public function clearEffectiveGaiaUserId(){ + public function clearUsername(){ return $this->_clear(2); } /** - * Get value + * Get value * - * @return int + * @return string */ - public function getEffectiveGaiaUserId(){ + public function getUsername(){ return $this->_get(2); } /** - * Set value + * Set value * - * @param int $value + * @param string $value * @return \grpc\testing\SimpleResponse */ - public function setEffectiveGaiaUserId( $value){ + public function setUsername( $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 has a value + * Check if has a value * * @return boolean */ - public function hasValue(){ - return $this->_has(1); + public function hasOauthScope(){ + return $this->_has(3); } /** - * Clear value + * Clear value * - * @return \grpc\testing\SimpleContext + * @return \grpc\testing\SimpleResponse */ - public function clearValue(){ - return $this->_clear(1); + public function clearOauthScope(){ + return $this->_clear(3); } /** - * Get value + * Get value * * @return string */ - public function getValue(){ - return $this->_get(1); + public function getOauthScope(){ + return $this->_get(3); } /** - * Set value + * Set value * * @param string $value - * @return \grpc\testing\SimpleContext + * @return \grpc\testing\SimpleResponse */ - public function setValue( $value){ - return $this->_set(1, $value); + public function setOauthScope( $value){ + return $this->_set(3, $value); } } } @@ -997,15 +1072,3 @@ namespace grpc\testing { } } -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 index fe6d0fb6c45..060a21def6d 100755 --- a/src/php/tests/interop/test.php +++ b/src/php/tests/interop/test.php @@ -1,52 +1,52 @@ _simpleRequest('/TestService/EmptyCall', $argument, '\proto2\EmptyMessage::deserialize', $metadata); + public function EmptyCall(\grpc\testing\EmptyMessage $argument, $metadata = array()) { + return $this->_simpleRequest('/grpc.testing.TestService/EmptyCall', $argument, '\grpc\testing\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); + return $this->_simpleRequest('/grpc.testing.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); + return $this->_serverStreamRequest('/grpc.testing.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); + return $this->_clientStreamRequest('/grpc.testing.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); + return $this->_bidiRequest('/grpc.testing.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); + return $this->_bidiRequest('/grpc.testing.TestService/HalfDuplexCall', '\grpc\testing\StreamingOutputCallResponse::deserialize', $metadata); } } }