From 7d8bbfa334456f8d749ec7653bcf3660913362f3 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Jan 2021 19:07:53 +0000 Subject: [PATCH 1/2] replace annotations to expectException() --- .../AbstractGeneratedCodeTest.php | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index a68954606f7..0f34810fe17 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -52,21 +52,17 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase $this->assertTrue(is_string(self::$client->getTarget())); } - /** - * @expectedException InvalidArgumentException - */ public function testClose() { + $this->expectException(\InvalidArgumentException::class); self::$client->close(); $div_arg = new Math\DivArgs(); $call = self::$client->Div($div_arg); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidMetadata() { + $this->expectException(\InvalidArgumentException::class); $div_arg = new Math\DivArgs(); $call = self::$client->Div($div_arg, [' ' => 'abc123']); } @@ -89,11 +85,9 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase $call = self::$client->Div($div_arg, ['someKEY._-1' => ['abc123']]); } - /** - * @expectedException InvalidArgumentException - */ public function testMetadataInvalidKey() { + $this->expectException(\InvalidArgumentException::class); $div_arg = new Math\DivArgs(); $call = self::$client->Div($div_arg, ['(somekey)' => ['abc123']]); } @@ -152,11 +146,9 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidMethodName() { + $this->expectException(\InvalidArgumentException::class); $invalid_client = new DummyInvalidClient('host', [ 'credentials' => Grpc\ChannelCredentials::createInsecure(), ]); @@ -164,11 +156,10 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase $invalid_client->InvalidUnaryCall($div_arg); } - /** - * @expectedException Exception - */ public function testMissingCredentials() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage("The opts['credentials'] key is now required."); $invalid_client = new DummyInvalidClient('host', [ ]); } From 806a0a85e1aa193570e7d5edc6e7f9f38b5c4367 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Jan 2021 19:32:03 +0000 Subject: [PATCH 2/2] fix no assert warnings --- .../generated_code/AbstractGeneratedCodeTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php index 0f34810fe17..7419e64f2a9 100644 --- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php +++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php @@ -70,19 +70,32 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase public function testMetadata() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, ['somekey' => ['abc123']]); + // $this->assertNotNull($call); + list($response, $status) = $call->wait(); + $this->assertSame(\Grpc\STATUS_OK, $status->code); } public function testMetadataKey() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, ['somekey_-1' => ['abc123']]); + list($response, $status) = $call->wait(); + $this->assertSame(\Grpc\STATUS_OK, $status->code); } public function testMetadataKeyWithDot() { $div_arg = new Math\DivArgs(); + $div_arg->setDividend(7); + $div_arg->setDivisor(4); $call = self::$client->Div($div_arg, ['someKEY._-1' => ['abc123']]); + list($response, $status) = $call->wait(); + $this->assertSame(\Grpc\STATUS_OK, $status->code); } public function testMetadataInvalidKey() @@ -170,6 +183,7 @@ abstract class AbstractGeneratedCodeTest extends \PHPUnit\Framework\TestCase 'credentials' => Grpc\ChannelCredentials::createInsecure(), 'grpc.primary_user_agent' => 'testUserAgent', ]); + $this->assertTrue(TRUE); // to avoid no assert warning } public function testWriteFlags()