diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c index bc4fcf07c9c..47ea38db0c9 100644 --- a/src/php/ext/grpc/server.c +++ b/src/php/ext/grpc/server.c @@ -146,7 +146,7 @@ PHP_METHOD(Server, add_http2_port) { "add_http2_port expects a string", 1 TSRMLS_CC); return; } - RETURN_BOOL(grpc_server_add_http2_port(server->wrapped, addr)); + RETURN_LONG(grpc_server_add_http2_port(server->wrapped, addr)); } PHP_METHOD(Server, add_secure_http2_port) { @@ -161,7 +161,7 @@ PHP_METHOD(Server, add_secure_http2_port) { "add_http2_port expects a string", 1 TSRMLS_CC); return; } - RETURN_BOOL(grpc_server_add_secure_http2_port(server->wrapped, addr)); + RETURN_LONG(grpc_server_add_secure_http2_port(server->wrapped, addr)); } /** diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php index 795831cb65c..ebf2ba34dda 100755 --- a/src/php/tests/unit_tests/CallTest.php +++ b/src/php/tests/unit_tests/CallTest.php @@ -1,16 +1,17 @@ add_http2_port('localhost:9001'); + self::$port = self::$server->add_http2_port('0.0.0.0:0'); } public function setUp() { $this->cq = new Grpc\CompletionQueue(); - $this->channel = new Grpc\Channel('localhost:9001', []); + $this->channel = new Grpc\Channel('localhost:' . self::$port, []); $this->call = new Grpc\Call($this->channel, '/foo', Grpc\Timeval::inf_future()); diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php index a2d8029b047..05104c0e121 100755 --- a/src/php/tests/unit_tests/EndToEndTest.php +++ b/src/php/tests/unit_tests/EndToEndTest.php @@ -1,13 +1,11 @@ client_queue = new Grpc\CompletionQueue(); $this->server_queue = new Grpc\CompletionQueue(); $this->server = new Grpc\Server($this->server_queue, []); - $address = '127.0.0.1:' . getNewPort(); - $this->server->add_http2_port($address); - $this->channel = new Grpc\Channel($address, []); + $port = $this->server->add_http2_port('0.0.0.0:0'); + $this->channel = new Grpc\Channel('localhost:' . $port, []); } public function tearDown() { diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php index 7ba4984bd86..5e95b11b44e 100755 --- a/src/php/tests/unit_tests/SecureEndToEndTest.php +++ b/src/php/tests/unit_tests/SecureEndToEndTest.php @@ -11,10 +11,9 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ file_get_contents(dirname(__FILE__) . '/../data/server1.pem')); $this->server = new Grpc\Server($this->server_queue, ['credentials' => $server_credentials]); - $address = '127.0.0.1:' . getNewPort(); - $this->server->add_secure_http2_port($address); + $port = $this->server->add_secure_http2_port('0.0.0.0:0'); $this->channel = new Grpc\Channel( - $address, + 'localhost:' . $port, [ 'grpc.ssl_target_name_override' => 'foo.test.google.com', 'credentials' => $credentials diff --git a/src/php/tests/util/port_picker.php b/src/php/tests/util/port_picker.php deleted file mode 100755 index d869d8b0a49..00000000000 --- a/src/php/tests/util/port_picker.php +++ /dev/null @@ -1,6 +0,0 @@ -