Skip to content
Snippets Groups Projects
Commit 1a3f4a55 authored by Stanley Cheung's avatar Stanley Cheung
Browse files

PHP: make tests runnable on both protobuf 3.1 and 3.2

parent c88834ba
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"require": { "require": {
"php": ">=5.5.0", "php": ">=5.5.0",
"ext-grpc": "*",
"google/protobuf": "v3.1.0-alpha-1" "google/protobuf": "v3.1.0-alpha-1"
}, },
"require-dev": { "require-dev": {
......
...@@ -134,29 +134,15 @@ void PrintService(const ServiceDescriptor *service, Printer *out) { ...@@ -134,29 +134,15 @@ void PrintService(const ServiceDescriptor *service, Printer *out) {
out->Outdent(); out->Outdent();
out->Print("}\n\n"); out->Print("}\n\n");
} }
void PrintServices(const FileDescriptor *file, Printer *out) {
map<grpc::string, grpc::string> vars;
vars["package"] = MessageIdentifierName(file->package());
out->Print(vars, "namespace $package$ {\n\n");
out->Indent();
for (int i = 0; i < file->service_count(); i++) {
PrintService(file->service(i), out);
}
out->Outdent();
out->Print("}\n");
}
} }
grpc::string GenerateFile(const FileDescriptor *file) { grpc::string GenerateFile(const FileDescriptor *file,
const ServiceDescriptor *service) {
grpc::string output; grpc::string output;
{ {
StringOutputStream output_stream(&output); StringOutputStream output_stream(&output);
Printer out(&output_stream, '$'); Printer out(&output_stream, '$');
if (file->service_count() == 0) {
return output;
}
out.Print("<?php\n"); out.Print("<?php\n");
out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n");
...@@ -166,7 +152,15 @@ grpc::string GenerateFile(const FileDescriptor *file) { ...@@ -166,7 +152,15 @@ grpc::string GenerateFile(const FileDescriptor *file) {
out.Print(leading_comments.c_str()); out.Print(leading_comments.c_str());
} }
PrintServices(file, &out); map<grpc::string, grpc::string> vars;
vars["package"] = MessageIdentifierName(file->package());
out.Print(vars, "namespace $package$ {\n\n");
out.Indent();
PrintService(service, &out);
out.Outdent();
out.Print("}\n");
} }
return output; return output;
} }
......
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
namespace grpc_php_generator { namespace grpc_php_generator {
grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file); grpc::string GenerateFile(const grpc::protobuf::FileDescriptor *file,
const grpc::protobuf::ServiceDescriptor *service);
} // namespace grpc_php_generator } // namespace grpc_php_generator
......
...@@ -41,14 +41,23 @@ ...@@ -41,14 +41,23 @@
namespace grpc_php_generator { namespace grpc_php_generator {
inline grpc::string GetPHPServiceFilename(const grpc::string& filename) { inline grpc::string GetPHPServiceFilename(
return grpc_generator::StripProto(filename) + "_grpc_pb.php"; const grpc::protobuf::FileDescriptor *file,
const grpc::protobuf::ServiceDescriptor *service) {
std::vector<grpc::string> tokens =
grpc_generator::tokenize(file->package(), ".");
std::ostringstream oss;
for (unsigned int i = 0; i < tokens.size(); i++) {
oss << (i == 0 ? "" : "/")
<< grpc_generator::CapitalizeFirstLetter(tokens[i]);
}
return oss.str() + "/" + service->name() + "Client.php";
} }
// Get leading or trailing comments in a string. Comment lines start with "// ". // Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments. // Leading detached comments are put in in front of leading comments.
template <typename DescriptorType> template <typename DescriptorType>
inline grpc::string GetPHPComments(const DescriptorType* desc, inline grpc::string GetPHPComments(const DescriptorType *desc,
grpc::string prefix) { grpc::string prefix) {
return grpc_generator::GetPrefixedComments(desc, true, prefix); return grpc_generator::GetPrefixedComments(desc, true, prefix);
} }
......
...@@ -51,18 +51,22 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ...@@ -51,18 +51,22 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
const grpc::string &parameter, const grpc::string &parameter,
grpc::protobuf::compiler::GeneratorContext *context, grpc::protobuf::compiler::GeneratorContext *context,
grpc::string *error) const { grpc::string *error) const {
grpc::string code = GenerateFile(file); if (file->service_count() == 0) {
if (code.size() == 0) {
return true; return true;
} }
// Get output file name for (int i = 0; i < file->service_count(); i++) {
grpc::string file_name = GetPHPServiceFilename(file->name()); grpc::string code = GenerateFile(file, file->service(i));
// Get output file name
grpc::string file_name = GetPHPServiceFilename(file, file->service(i));
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->Open(file_name));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
coded_out.WriteRaw(code.data(), code.size());
}
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output(
context->Open(file_name));
grpc::protobuf::io::CodedOutputStream coded_out(output.get());
coded_out.WriteRaw(code.data(), code.size());
return true; return true;
} }
}; };
......
{ {
"name": "grpc/grpc", "name": "grpc/grpc-dev",
"type": "library", "description": "gRPC library for PHP - for Developement use only",
"description": "gRPC library for PHP",
"keywords": ["rpc"],
"homepage": "http://grpc.io",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"version": "1.1.0", "version": "1.1.0",
"require": { "require": {
"php": ">=5.5.0", "php": ">=5.5.0",
"ext-grpc": "*",
"google/protobuf": "v3.1.0-alpha-1" "google/protobuf": "v3.1.0-alpha-1"
}, },
"require-dev": { "require-dev": {
...@@ -16,7 +12,11 @@ ...@@ -16,7 +12,11 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Grpc\\": "lib/Grpc/" "Grpc\\": "lib/Grpc/",
"Grpc\\Testing\\": "tests/interop/Grpc/Testing/",
"GPBMetadata\\Src\\Proto\\Grpc\\Testing\\": "tests/interop/GPBMetadata/Src/Proto/Grpc/Testing/",
"Math\\": "tests/generated_code/Math/",
"GPBMetadata\\": "tests/generated_code/GPBMetadata/"
} }
} }
} }
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
* *
*/ */
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php'); require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
require_once dirname(__FILE__).'/math.pb.php'; @include_once dirname(__FILE__).'/math.pb.php';
require_once dirname(__FILE__).'/math_grpc_pb.php'; @include_once dirname(__FILE__).'/math_grpc_pb.php';
abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
{ {
...@@ -70,7 +70,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -70,7 +70,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testClose() public function testClose()
{ {
self::$client->close(); self::$client->close();
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg); $call = self::$client->Div($div_arg);
} }
...@@ -79,20 +79,20 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -79,20 +79,20 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
*/ */
public function testInvalidMetadata() public function testInvalidMetadata()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg, [' ' => 'abc123']); $call = self::$client->Div($div_arg, [' ' => 'abc123']);
} }
public function testGetCallMetadata() public function testGetCallMetadata()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg); $call = self::$client->Div($div_arg);
$this->assertTrue(is_array($call->getMetadata())); $this->assertTrue(is_array($call->getMetadata()));
} }
public function testTimeout() public function testTimeout()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg, [], ['timeout' => 1]); $call = self::$client->Div($div_arg, [], ['timeout' => 1]);
list($response, $status) = $call->wait(); list($response, $status) = $call->wait();
$this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code); $this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code);
...@@ -100,7 +100,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -100,7 +100,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testCancel() public function testCancel()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg); $call = self::$client->Div($div_arg);
$call->cancel(); $call->cancel();
list($response, $status) = $call->wait(); list($response, $status) = $call->wait();
...@@ -109,7 +109,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -109,7 +109,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testCallCredentialsCallback() public function testCallCredentialsCallback()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg, array(), array( $call = self::$client->Div($div_arg, array(), array(
'call_credentials_callback' => function ($context) { 'call_credentials_callback' => function ($context) {
return array(); return array();
...@@ -122,7 +122,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -122,7 +122,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testCallCredentialsCallback2() public function testCallCredentialsCallback2()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$call = self::$client->Div($div_arg); $call = self::$client->Div($div_arg);
$call_credentials = Grpc\CallCredentials::createFromPlugin( $call_credentials = Grpc\CallCredentials::createFromPlugin(
function ($context) { function ($context) {
...@@ -143,7 +143,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -143,7 +143,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
$invalid_client = new DummyInvalidClient('host', [ $invalid_client = new DummyInvalidClient('host', [
'credentials' => Grpc\ChannelCredentials::createInsecure(), 'credentials' => Grpc\ChannelCredentials::createInsecure(),
]); ]);
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$invalid_client->InvalidUnaryCall($div_arg); $invalid_client->InvalidUnaryCall($div_arg);
} }
...@@ -166,7 +166,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -166,7 +166,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testWriteFlags() public function testWriteFlags()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$div_arg->setDividend(7); $div_arg->setDividend(7);
$div_arg->setDivisor(4); $div_arg->setDivisor(4);
$call = self::$client->Div($div_arg, [], $call = self::$client->Div($div_arg, [],
...@@ -180,7 +180,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -180,7 +180,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testWriteFlagsServerStreaming() public function testWriteFlagsServerStreaming()
{ {
$fib_arg = new math\FibArgs(); $fib_arg = new Math\FibArgs();
$fib_arg->setLimit(7); $fib_arg->setLimit(7);
$call = self::$client->Fib($fib_arg, [], $call = self::$client->Fib($fib_arg, [],
['flags' => Grpc\WRITE_NO_COMPRESS]); ['flags' => Grpc\WRITE_NO_COMPRESS]);
...@@ -192,7 +192,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -192,7 +192,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testWriteFlagsClientStreaming() public function testWriteFlagsClientStreaming()
{ {
$call = self::$client->Sum(); $call = self::$client->Sum();
$num = new math\Num(); $num = new Math\Num();
$num->setNum(1); $num->setNum(1);
$call->write($num, ['flags' => Grpc\WRITE_NO_COMPRESS]); $call->write($num, ['flags' => Grpc\WRITE_NO_COMPRESS]);
list($response, $status) = $call->wait(); list($response, $status) = $call->wait();
...@@ -202,7 +202,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -202,7 +202,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testWriteFlagsBidiStreaming() public function testWriteFlagsBidiStreaming()
{ {
$call = self::$client->DivMany(); $call = self::$client->DivMany();
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$div_arg->setDividend(7); $div_arg->setDividend(7);
$div_arg->setDivisor(4); $div_arg->setDivisor(4);
$call->write($div_arg, ['flags' => Grpc\WRITE_NO_COMPRESS]); $call->write($div_arg, ['flags' => Grpc\WRITE_NO_COMPRESS]);
...@@ -214,7 +214,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -214,7 +214,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testSimpleRequest() public function testSimpleRequest()
{ {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$div_arg->setDividend(7); $div_arg->setDividend(7);
$div_arg->setDivisor(4); $div_arg->setDivisor(4);
$call = self::$client->Div($div_arg); $call = self::$client->Div($div_arg);
...@@ -227,7 +227,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -227,7 +227,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
public function testServerStreaming() public function testServerStreaming()
{ {
$fib_arg = new math\FibArgs(); $fib_arg = new Math\FibArgs();
$fib_arg->setLimit(7); $fib_arg->setLimit(7);
$call = self::$client->Fib($fib_arg); $call = self::$client->Fib($fib_arg);
$this->assertTrue(is_string($call->getPeer())); $this->assertTrue(is_string($call->getPeer()));
...@@ -246,7 +246,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -246,7 +246,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
$call = self::$client->Sum(); $call = self::$client->Sum();
$this->assertTrue(is_string($call->getPeer())); $this->assertTrue(is_string($call->getPeer()));
for ($i = 0; $i < 7; ++$i) { for ($i = 0; $i < 7; ++$i) {
$num = new math\Num(); $num = new Math\Num();
$num->setNum($i); $num->setNum($i);
$call->write($num); $call->write($num);
} }
...@@ -260,7 +260,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -260,7 +260,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
$call = self::$client->DivMany(); $call = self::$client->DivMany();
$this->assertTrue(is_string($call->getPeer())); $this->assertTrue(is_string($call->getPeer()));
for ($i = 0; $i < 7; ++$i) { for ($i = 0; $i < 7; ++$i) {
$div_arg = new math\DivArgs(); $div_arg = new Math\DivArgs();
$div_arg->setDividend(2 * $i + 1); $div_arg->setDividend(2 * $i + 1);
$div_arg->setDivisor(2); $div_arg->setDivisor(2);
$call->write($div_arg); $call->write($div_arg);
...@@ -276,7 +276,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase ...@@ -276,7 +276,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
class DummyInvalidClient extends \Grpc\BaseStub class DummyInvalidClient extends \Grpc\BaseStub
{ {
public function InvalidUnaryCall(\math\DivArgs $argument, public function InvalidUnaryCall(\Math\DivArgs $argument,
$metadata = [], $metadata = [],
$options = []) $options = [])
{ {
......
...@@ -37,7 +37,7 @@ class GeneratedCodeTest extends AbstractGeneratedCodeTest ...@@ -37,7 +37,7 @@ class GeneratedCodeTest extends AbstractGeneratedCodeTest
{ {
public function setUp() public function setUp()
{ {
self::$client = new math\MathClient( self::$client = new Math\MathClient(
getenv('GRPC_TEST_HOST'), [ getenv('GRPC_TEST_HOST'), [
'credentials' => Grpc\ChannelCredentials::createInsecure(), 'credentials' => Grpc\ChannelCredentials::createInsecure(),
]); ]);
......
...@@ -37,7 +37,7 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest ...@@ -37,7 +37,7 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest
{ {
public function setUp() public function setUp()
{ {
self::$client = new math\MathClient( self::$client = new Math\MathClient(
getenv('GRPC_TEST_HOST'), getenv('GRPC_TEST_HOST'),
['credentials' => Grpc\ChannelCredentials::createInsecure(), ['credentials' => Grpc\ChannelCredentials::createInsecure(),
'update_metadata' => function ($a_hash, 'update_metadata' => function ($a_hash,
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
* *
*/ */
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php'); require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
require 'src/proto/grpc/testing/test.pb.php'; @include_once 'src/proto/grpc/testing/test.pb.php';
require 'src/proto/grpc/testing/test_grpc_pb.php'; @include_once 'src/proto/grpc/testing/test_grpc_pb.php';
use Google\Auth\CredentialsLoader; use Google\Auth\CredentialsLoader;
use Google\Auth\ApplicationDefaultCredentials; use Google\Auth\ApplicationDefaultCredentials;
use GuzzleHttp\ClientInterface; use GuzzleHttp\ClientInterface;
...@@ -70,7 +70,7 @@ function hardAssertIfStatusOk($status) ...@@ -70,7 +70,7 @@ function hardAssertIfStatusOk($status)
function emptyUnary($stub) function emptyUnary($stub)
{ {
list($result, $status) = list($result, $status) =
$stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); $stub->EmptyCall(new Grpc\Testing\EmptyMessage())->wait();
hardAssertIfStatusOk($status); hardAssertIfStatusOk($status);
hardAssert($result !== null, 'Call completed with a null response'); hardAssert($result !== null, 'Call completed with a null response');
} }
...@@ -98,11 +98,11 @@ function performLargeUnary($stub, $fillUsername = false, ...@@ -98,11 +98,11 @@ function performLargeUnary($stub, $fillUsername = false,
$request_len = 271828; $request_len = 271828;
$response_len = 314159; $response_len = 314159;
$request = new grpc\testing\SimpleRequest(); $request = new Grpc\Testing\SimpleRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
$request->setResponseSize($response_len); $request->setResponseSize($response_len);
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setType(grpc\testing\PayloadType::COMPRESSABLE); $payload->setType(Grpc\Testing\PayloadType::COMPRESSABLE);
$payload->setBody(str_repeat("\0", $request_len)); $payload->setBody(str_repeat("\0", $request_len));
$request->setPayload($payload); $request->setPayload($payload);
$request->setFillUsername($fillUsername); $request->setFillUsername($fillUsername);
...@@ -117,7 +117,7 @@ function performLargeUnary($stub, $fillUsername = false, ...@@ -117,7 +117,7 @@ function performLargeUnary($stub, $fillUsername = false,
hardAssertIfStatusOk($status); hardAssertIfStatusOk($status);
hardAssert($result !== null, 'Call returned a null response'); hardAssert($result !== null, 'Call returned a null response');
$payload = $result->getPayload(); $payload = $result->getPayload();
hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, hardAssert($payload->getType() === Grpc\Testing\PayloadType::COMPRESSABLE,
'Payload had the wrong type'); 'Payload had the wrong type');
hardAssert(strlen($payload->getBody()) === $response_len, hardAssert(strlen($payload->getBody()) === $response_len,
'Payload had the wrong length'); 'Payload had the wrong length');
...@@ -249,8 +249,8 @@ function clientStreaming($stub) ...@@ -249,8 +249,8 @@ function clientStreaming($stub)
$requests = array_map( $requests = array_map(
function ($length) { function ($length) {
$request = new grpc\testing\StreamingInputCallRequest(); $request = new Grpc\Testing\StreamingInputCallRequest();
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setBody(str_repeat("\0", $length)); $payload->setBody(str_repeat("\0", $length));
$request->setPayload($payload); $request->setPayload($payload);
...@@ -276,10 +276,10 @@ function serverStreaming($stub) ...@@ -276,10 +276,10 @@ function serverStreaming($stub)
{ {
$sizes = [31415, 9, 2653, 58979]; $sizes = [31415, 9, 2653, 58979];
$request = new grpc\testing\StreamingOutputCallRequest(); $request = new Grpc\Testing\StreamingOutputCallRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
foreach ($sizes as $size) { foreach ($sizes as $size) {
$response_parameters = new grpc\testing\ResponseParameters(); $response_parameters = new Grpc\Testing\ResponseParameters();
$response_parameters->setSize($size); $response_parameters->setSize($size);
$request->getResponseParameters()[] = $response_parameters; $request->getResponseParameters()[] = $response_parameters;
} }
...@@ -290,7 +290,7 @@ function serverStreaming($stub) ...@@ -290,7 +290,7 @@ function serverStreaming($stub)
hardAssert($i < 4, 'Too many responses'); hardAssert($i < 4, 'Too many responses');
$payload = $value->getPayload(); $payload = $value->getPayload();
hardAssert( hardAssert(
$payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, $payload->getType() === Grpc\Testing\PayloadType::COMPRESSABLE,
'Payload '.$i.' had the wrong type'); 'Payload '.$i.' had the wrong type');
hardAssert(strlen($payload->getBody()) === $sizes[$i], hardAssert(strlen($payload->getBody()) === $sizes[$i],
'Response '.$i.' had the wrong length'); 'Response '.$i.' had the wrong length');
...@@ -311,12 +311,12 @@ function pingPong($stub) ...@@ -311,12 +311,12 @@ function pingPong($stub)
$call = $stub->FullDuplexCall(); $call = $stub->FullDuplexCall();
for ($i = 0; $i < 4; ++$i) { for ($i = 0; $i < 4; ++$i) {
$request = new grpc\testing\StreamingOutputCallRequest(); $request = new Grpc\Testing\StreamingOutputCallRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
$response_parameters = new grpc\testing\ResponseParameters(); $response_parameters = new Grpc\Testing\ResponseParameters();
$response_parameters->setSize($response_lengths[$i]); $response_parameters->setSize($response_lengths[$i]);
$request->getResponseParameters()[] = $response_parameters; $request->getResponseParameters()[] = $response_parameters;
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setBody(str_repeat("\0", $request_lengths[$i])); $payload->setBody(str_repeat("\0", $request_lengths[$i]));
$request->setPayload($payload); $request->setPayload($payload);
...@@ -326,7 +326,7 @@ function pingPong($stub) ...@@ -326,7 +326,7 @@ function pingPong($stub)
hardAssert($response !== null, 'Server returned too few responses'); hardAssert($response !== null, 'Server returned too few responses');
$payload = $response->getPayload(); $payload = $response->getPayload();
hardAssert( hardAssert(
$payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, $payload->getType() === Grpc\Testing\PayloadType::COMPRESSABLE,
'Payload '.$i.' had the wrong type'); 'Payload '.$i.' had the wrong type');
hardAssert(strlen($payload->getBody()) === $response_lengths[$i], hardAssert(strlen($payload->getBody()) === $response_lengths[$i],
'Payload '.$i.' had the wrong length'); 'Payload '.$i.' had the wrong length');
...@@ -371,12 +371,12 @@ function cancelAfterBegin($stub) ...@@ -371,12 +371,12 @@ function cancelAfterBegin($stub)
function cancelAfterFirstResponse($stub) function cancelAfterFirstResponse($stub)
{ {
$call = $stub->FullDuplexCall(); $call = $stub->FullDuplexCall();
$request = new grpc\testing\StreamingOutputCallRequest(); $request = new Grpc\Testing\StreamingOutputCallRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
$response_parameters = new grpc\testing\ResponseParameters(); $response_parameters = new Grpc\Testing\ResponseParameters();
$response_parameters->setSize(31415); $response_parameters->setSize(31415);
$request->getResponseParameters()[] = $response_parameters; $request->getResponseParameters()[] = $response_parameters;
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setBody(str_repeat("\0", 27182)); $payload->setBody(str_repeat("\0", 27182));
$request->setPayload($payload); $request->setPayload($payload);
...@@ -391,12 +391,12 @@ function cancelAfterFirstResponse($stub) ...@@ -391,12 +391,12 @@ function cancelAfterFirstResponse($stub)
function timeoutOnSleepingServer($stub) function timeoutOnSleepingServer($stub)
{ {
$call = $stub->FullDuplexCall([], ['timeout' => 1000]); $call = $stub->FullDuplexCall([], ['timeout' => 1000]);
$request = new grpc\testing\StreamingOutputCallRequest(); $request = new Grpc\Testing\StreamingOutputCallRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
$response_parameters = new grpc\testing\ResponseParameters(); $response_parameters = new Grpc\Testing\ResponseParameters();
$response_parameters->setSize(8); $response_parameters->setSize(8);
$request->getResponseParameters()[] = $response_parameters; $request->getResponseParameters()[] = $response_parameters;
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setBody(str_repeat("\0", 9)); $payload->setBody(str_repeat("\0", 9));
$request->setPayload($payload); $request->setPayload($payload);
...@@ -416,11 +416,11 @@ function customMetadata($stub) ...@@ -416,11 +416,11 @@ function customMetadata($stub)
$request_len = 271828; $request_len = 271828;
$response_len = 314159; $response_len = 314159;
$request = new grpc\testing\SimpleRequest(); $request = new Grpc\Testing\SimpleRequest();
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE); $request->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE);
$request->setResponseSize($response_len); $request->setResponseSize($response_len);
$payload = new grpc\testing\Payload(); $payload = new Grpc\Testing\Payload();
$payload->setType(grpc\testing\PayloadType::COMPRESSABLE); $payload->setType(Grpc\Testing\PayloadType::COMPRESSABLE);
$payload->setBody(str_repeat("\0", $request_len)); $payload->setBody(str_repeat("\0", $request_len));
$request->setPayload($payload); $request->setPayload($payload);
...@@ -449,9 +449,9 @@ function customMetadata($stub) ...@@ -449,9 +449,9 @@ function customMetadata($stub)
$streaming_call = $stub->FullDuplexCall($metadata); $streaming_call = $stub->FullDuplexCall($metadata);
$streaming_request = new grpc\testing\StreamingOutputCallRequest(); $streaming_request = new Grpc\Testing\StreamingOutputCallRequest();
$streaming_request->setPayload($payload); $streaming_request->setPayload($payload);
$response_parameters = new grpc\testing\ResponseParameters(); $response_parameters = new Grpc\Testing\ResponseParameters();
$response_parameters->setSize($response_len); $response_parameters->setSize($response_len);
$streaming_request->getResponseParameters()[] = $response_parameters; $streaming_request->getResponseParameters()[] = $response_parameters;
$streaming_call->write($streaming_request); $streaming_call->write($streaming_request);
...@@ -477,11 +477,11 @@ function customMetadata($stub) ...@@ -477,11 +477,11 @@ function customMetadata($stub)
function statusCodeAndMessage($stub) function statusCodeAndMessage($stub)
{ {
$echo_status = new grpc\testing\EchoStatus(); $echo_status = new Grpc\Testing\EchoStatus();
$echo_status->setCode(2); $echo_status->setCode(2);
$echo_status->setMessage('test status message'); $echo_status->setMessage('test status message');
$request = new grpc\testing\SimpleRequest(); $request = new Grpc\Testing\SimpleRequest();
$request->setResponseStatus($echo_status); $request->setResponseStatus($echo_status);
$call = $stub->UnaryCall($request); $call = $stub->UnaryCall($request);
...@@ -496,7 +496,7 @@ function statusCodeAndMessage($stub) ...@@ -496,7 +496,7 @@ function statusCodeAndMessage($stub)
$streaming_call = $stub->FullDuplexCall(); $streaming_call = $stub->FullDuplexCall();
$streaming_request = new grpc\testing\StreamingOutputCallRequest(); $streaming_request = new Grpc\Testing\StreamingOutputCallRequest();
$streaming_request->setResponseStatus($echo_status); $streaming_request->setResponseStatus($echo_status);
$streaming_call->write($streaming_request); $streaming_call->write($streaming_request);
$streaming_call->writesDone(); $streaming_call->writesDone();
...@@ -514,7 +514,7 @@ function statusCodeAndMessage($stub) ...@@ -514,7 +514,7 @@ function statusCodeAndMessage($stub)
# NOTE: the stub input to this function is from UnimplementedService # NOTE: the stub input to this function is from UnimplementedService
function unimplementedService($stub) function unimplementedService($stub)
{ {
$call = $stub->UnimplementedCall(new grpc\testing\EmptyMessage()); $call = $stub->UnimplementedCall(new Grpc\Testing\EmptyMessage());
list($result, $status) = $call->wait(); list($result, $status) = $call->wait();
hardAssert($status->code === Grpc\STATUS_UNIMPLEMENTED, hardAssert($status->code === Grpc\STATUS_UNIMPLEMENTED,
'Received unexpected status code'); 'Received unexpected status code');
...@@ -523,7 +523,7 @@ function unimplementedService($stub) ...@@ -523,7 +523,7 @@ function unimplementedService($stub)
# NOTE: the stub input to this function is from TestService # NOTE: the stub input to this function is from TestService
function unimplementedMethod($stub) function unimplementedMethod($stub)
{ {
$call = $stub->UnimplementedCall(new grpc\testing\EmptyMessage()); $call = $stub->UnimplementedCall(new Grpc\Testing\EmptyMessage());
list($result, $status) = $call->wait(); list($result, $status) = $call->wait();
hardAssert($status->code === Grpc\STATUS_UNIMPLEMENTED, hardAssert($status->code === Grpc\STATUS_UNIMPLEMENTED,
'Received unexpected status code'); 'Received unexpected status code');
...@@ -614,10 +614,10 @@ function _makeStub($args) ...@@ -614,10 +614,10 @@ function _makeStub($args)
} }
if ($test_case === 'unimplemented_service') { if ($test_case === 'unimplemented_service') {
$stub = new grpc\testing\UnimplementedServiceClient($server_address, $stub = new Grpc\Testing\UnimplementedServiceClient($server_address,
$opts); $opts);
} else { } else {
$stub = new grpc\testing\TestServiceClient($server_address, $opts); $stub = new Grpc\Testing\TestServiceClient($server_address, $opts);
} }
return $stub; return $stub;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"require": { "require": {
"php": ">=5.5.0", "php": ">=5.5.0",
"ext-grpc": "*",
"google/protobuf": "v3.1.0-alpha-1" "google/protobuf": "v3.1.0-alpha-1"
}, },
"require-dev": { "require-dev": {
......
%YAML 1.2 %YAML 1.2
--- | --- |
{ {
"name": "grpc/grpc", "name": "grpc/grpc-dev",
"type": "library", "description": "gRPC library for PHP - for Developement use only",
"description": "gRPC library for PHP",
"keywords": ["rpc"],
"homepage": "http://grpc.io",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"version": "${settings.php_version.php_composer()}", "version": "${settings.php_version.php_composer()}",
"require": { "require": {
"php": ">=5.5.0", "php": ">=5.5.0",
"ext-grpc": "*",
"google/protobuf": "v3.1.0-alpha-1" "google/protobuf": "v3.1.0-alpha-1"
}, },
"require-dev": { "require-dev": {
...@@ -18,7 +14,11 @@ ...@@ -18,7 +14,11 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Grpc\\": "lib/Grpc/" "Grpc\\": "lib/Grpc/",
"Grpc\\Testing\\": "tests/interop/Grpc/Testing/",
"GPBMetadata\\Src\\Proto\\Grpc\\Testing\\": "tests/interop/GPBMetadata/Src/Proto/Grpc/Testing/",
"Math\\": "tests/generated_code/Math/",
"GPBMetadata\\": "tests/generated_code/GPBMetadata/"
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment