aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php
diff options
context:
space:
mode:
authorGravatar murgatroid99 <michael.lumish@gmail.com>2015-02-03 17:44:50 -0800
committerGravatar murgatroid99 <michael.lumish@gmail.com>2015-02-03 17:44:50 -0800
commitd96db79b92e089fc1a18a0d11d06fffdcf892033 (patch)
tree3d605de98a6dea897bb8eefdc996fe5380169272 /src/php
parent8c0596edcaf00680eea55455471cba84ccf8061e (diff)
Switched to binding servers to port 0 in tests
Diffstat (limited to 'src/php')
-rw-r--r--src/php/ext/grpc/server.c4
-rwxr-xr-xsrc/php/tests/unit_tests/CallTest.php5
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php6
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php5
-rwxr-xr-xsrc/php/tests/util/port_picker.php6
5 files changed, 9 insertions, 17 deletions
diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c
index bc4fcf07c9..47ea38db0c 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 795831cb65..ebf2ba34dd 100755
--- a/src/php/tests/unit_tests/CallTest.php
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -1,16 +1,17 @@
<?php
class CallTest extends PHPUnit_Framework_TestCase{
static $server;
+ static $port;
public static function setUpBeforeClass() {
$cq = new Grpc\CompletionQueue();
self::$server = new Grpc\Server($cq, []);
- self::$server->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 a2d8029b04..05104c0e12 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -1,13 +1,11 @@
<?php
-require __DIR__ . '/../util/port_picker.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, []);
- $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 7ba4984bd8..5e95b11b44 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 d869d8b0a4..0000000000
--- a/src/php/tests/util/port_picker.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-function getNewPort() {
- static $port = 10000;
- $port += 1;
- return $port;
-} \ No newline at end of file