diff --git a/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java b/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java index 371a8718f7..296e8d8d15 100644 --- a/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java @@ -246,6 +246,7 @@ private List createTestCaseViews(GapicInterfaceContext context) { } private void addUnitTestImports(ModelTypeTable typeTable) { + typeTable.saveNicknameFor("\\Google\\GAX\\ApiException"); typeTable.saveNicknameFor("\\Google\\GAX\\GrpcCredentialsHelper"); typeTable.saveNicknameFor("\\Google\\GAX\\LongRunning\\OperationsClient"); typeTable.saveNicknameFor("\\Google\\GAX\\Testing\\MockStubTrait"); @@ -254,5 +255,7 @@ private void addUnitTestImports(ModelTypeTable typeTable) { typeTable.saveNicknameFor("\\google\\protobuf\\Any"); typeTable.saveNicknameFor("\\google\\protobuf\\EmptyC"); typeTable.saveNicknameFor("\\google\\longrunning\\GetOperationRequest"); + typeTable.saveNicknameFor("\\Grpc"); + typeTable.saveNicknameFor("\\stdClass"); } } diff --git a/src/main/resources/com/google/api/codegen/php/test.snip b/src/main/resources/com/google/api/codegen/php/test.snip index a918e4b01b..fed9dc2d4f 100644 --- a/src/main/resources/com/google/api/codegen/php/test.snip +++ b/src/main/resources/com/google/api/codegen/php/test.snip @@ -67,128 +67,220 @@ @end @private nonStreamingOptionalArrayTestCase(test) + @switch test.clientMethodType + @case "OptionalArrayMethod" + {@simpleTestCase(test)} + {@simpleExceptionTestCase(test)} + @case "PagedOptionalArrayMethod" + {@pageStreamingTestCase(test)} + {@simpleExceptionTestCase(test)} + @case "OperationOptionalArrayMethod" + {@lroTestCase(test)} + {@lroExceptionTestCase(test)} + @default + $unhandled case: {@test.clientMethodType}$ + @end +@end + +@private simpleTestCase(test) /** * @@test */ public function {@test.name}() { - @switch test.clientMethodType - @case "OptionalArrayMethod" - {@simpleTestCase(test)} - @case "PagedOptionalArrayMethod" - {@pageStreamingTestCase(test)} - @case "OperationOptionalArrayMethod" - {@lroTestCase(test)} - @default - $unhandled case: {@test.clientMethodType}$ + {@singleCallTestSetup(test)} + @if test.hasReturnValue + $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); + $this->assertEquals($expectedResponse, $response); + @else + $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); @end + {@singleCallSuccessAsserts(test)} + + $this->assertTrue($grpcStub->isExhausted()); } @end -@private simpleTestCase(test) - {@singleCallTestSetup(test)} - @if test.hasReturnValue +@private pageStreamingTestCase(test) + /** + * @@test + */ + public function {@test.name}() + { + {@singleCallTestSetup(test)} $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); - $this->assertEquals($expectedResponse, $response); - @else - $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); - @end - {@singleCallSuccessAsserts(test)} + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + @join pageStreamingResponseView : test.pageStreamingResponseViews + ${@pageStreamingResponseView.resourcesVarName} = iterator_to_array($response->{@pageStreamingResponseView.resourcesIterateMethod}()); + $this->assertSame(1, count(${@pageStreamingResponseView.resourcesVarName})); + $this->assertEquals($expectedResponse->{@pageStreamingResponseView.resourcesFieldGetterName}()[0], ${@pageStreamingResponseView.resourcesVarName}[0]); + @end - $this->assertTrue($grpcStub->isExhausted()); + {@singleCallSuccessAsserts(test)} + $this->assertTrue($grpcStub->isExhausted()); + } @end -@private pageStreamingTestCase(test) - {@singleCallTestSetup(test)} - $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - @join pageStreamingResponseView : test.pageStreamingResponseViews - ${@pageStreamingResponseView.resourcesVarName} = iterator_to_array($response->{@pageStreamingResponseView.resourcesIterateMethod}()); - $this->assertSame(1, count(${@pageStreamingResponseView.resourcesVarName})); - $this->assertEquals($expectedResponse->{@pageStreamingResponseView.resourcesFieldGetterName}()[0], ${@pageStreamingResponseView.resourcesVarName}[0]); - @end +@private simpleExceptionTestCase(test) - {@singleCallSuccessAsserts(test)} - $this->assertTrue($grpcStub->isExhausted()); -@end + /** + * @@test + */ + public function {@test.nameWithException}() + { + $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']); + $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub); -@private lroTestCase(test) - $operationsStub = $this->createStub([$this, 'createMockOperationsStub']); - $operationsClient = new OperationsClient([ - 'serviceAddress' => '', - 'scopes' => [], - 'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) { - return $operationsStub; - } - ]); - $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']); - $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [ - 'operationsClient' => $operationsClient - ]); + $this->assertTrue($grpcStub->isExhausted()); - $this->assertTrue($grpcStub->isExhausted()); - $this->assertTrue($operationsStub->isExhausted()); + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/{@test.name}')->setDone(false); - $grpcStub->addResponse($incompleteOperation); - @if test.hasReturnValue - {@initCode(test.mockResponse.initCode)} - @else - $expectedResponse = new EmptyC(); - @end - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serialize()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/{@test.name}')->setDone(true)->setResponse($anyResponse); - $operationsStub->addResponse($completeOperation); + @if test.hasRequestParameters + // Mock request + {@initCode(test.initCode)} - @if test.hasRequestParameters - // Mock request - {@initCode(test.initCode)} + @end + try { + $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } - @end - $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $grpcStub->getReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsStub->getReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); + $this->assertTrue($grpcStub->isExhausted()); + } +@end - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('{@test.grpcStubCallString}', $actualApiFuncCall); - @join assert : test.asserts - @if assert.hasExpectedValueTransformFunction - $this->assertEquals({@assert.expectedValueTransformFunction}(\ - ${@assert.expectedValueIdentifier}), \ - $actualApiRequestObject->{@assert.actualValueGetter}()); +@private lroTestCase(test) + /** + * @@test + */ + public function {@test.name}() + { + $operationsStub = $this->createStub([$this, 'createMockOperationsStub']); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'scopes' => [], + 'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) { + return $operationsStub; + } + ]); + $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']); + $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [ + 'operationsClient' => $operationsClient + ]); + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/{@test.name}')->setDone(false); + $grpcStub->addResponse($incompleteOperation); + @if test.hasReturnValue + {@initCode(test.mockResponse.initCode)} @else - $this->assertEquals(${@assert.expectedValueIdentifier}, \ - $actualApiRequestObject->{@assert.actualValueGetter}()); + $expectedResponse = new EmptyC(); @end - @end + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serialize()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/{@test.name}')->setDone(true)->setResponse($anyResponse); + $operationsStub->addResponse($completeOperation); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/{@test.name}'); + @if test.hasRequestParameters + // Mock request + {@initCode(test.initCode)} - $response->pollUntilComplete(); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $grpcStub->getReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsStub->getReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); + @end + $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + {@lroCallSuccessAsserts(test)} - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/{@test.name}'); - $this->assertTrue($grpcStub->isExhausted()); - $this->assertTrue($operationsStub->isExhausted()); + $response->pollUntilComplete(); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $grpcStub->getReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsStub->getReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + } +@end + +@private lroExceptionTestCase(test) + + /** + * @@test + */ + public function {@test.nameWithException}() + { + $operationsStub = $this->createStub([$this, 'createMockOperationsStub']); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'scopes' => [], + 'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) { + return $operationsStub; + } + ]); + $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']); + $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [ + 'operationsClient' => $operationsClient + ]); + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/{@test.name}')->setDone(false); + $grpcStub->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $operationsStub->addResponse(null, $status); + + @if test.hasRequestParameters + // Mock request + {@initCode(test.initCode)} + + @end + $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)}); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/{@test.name}'); + + try { + $response->pollUntilComplete(); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + } @end @private singleCallTestSetup(test) @@ -197,15 +289,14 @@ $this->assertTrue($grpcStub->isExhausted()); + // Mock response @if test.hasReturnValue - // Mock response {@initCode(test.mockResponse.initCode)} - $grpcStub->addResponse($expectedResponse); - @else - // Add empty response to the grpc stub - $grpcStub->addResponse(new EmptyC()); + $expectedResponse = new EmptyC(); @end + $grpcStub->addResponse($expectedResponse); + @if test.hasRequestParameters // Mock request {@initCode(test.initCode)} @@ -231,3 +322,24 @@ @end @end @end + +@private lroCallSuccessAsserts(test) + $apiRequests = $grpcStub->getReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsStub->getReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('{@test.grpcStubCallString}', $actualApiFuncCall); + @join assert : test.asserts + @if assert.hasExpectedValueTransformFunction + $this->assertEquals({@assert.expectedValueTransformFunction}(\ + ${@assert.expectedValueIdentifier}), \ + $actualApiRequestObject->{@assert.actualValueGetter}()); + @else + $this->assertEquals(${@assert.expectedValueIdentifier}, \ + $actualApiRequestObject->{@assert.actualValueGetter}()); + @end + @end +@end diff --git a/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline b/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline index a42dedb80e..a722fcac0d 100644 --- a/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline +++ b/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline @@ -23,15 +23,18 @@ namespace Google\Tests\Example\Library\V1; +use \Google\GAX\ApiException; use \Google\GAX\GrpcCredentialsHelper; use \Google\GAX\LongRunning\OperationsClient; use \Google\GAX\Testing\LongRunning\MockOperationsImpl; use \Google\GAX\Testing\MockStubTrait; +use \Grpc; use \PHPUnit_Framework_TestCase; use \google\longrunning\GetOperationRequest; use \google\protobuf\Any; use \google\protobuf\EmptyC; use \google\tagger\v1\LabelerGrpcClient; +use \stdClass; class MockLabelerImpl extends LabelerGrpcClient { @@ -62,15 +65,18 @@ class MockLabelerImpl extends LabelerGrpcClient namespace Google\Tests\Example\Library\V1; +use \Google\GAX\ApiException; use \Google\GAX\GrpcCredentialsHelper; use \Google\GAX\LongRunning\OperationsClient; use \Google\GAX\Testing\LongRunning\MockOperationsImpl; use \Google\GAX\Testing\MockStubTrait; +use \Grpc; use \PHPUnit_Framework_TestCase; use \google\example\library\v1\LibraryServiceGrpcClient; use \google\longrunning\GetOperationRequest; use \google\protobuf\Any; use \google\protobuf\EmptyC; +use \stdClass; class MockLibraryServiceImpl extends LibraryServiceGrpcClient { diff --git a/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline index a525ae1f42..1d285e5bf5 100644 --- a/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline +++ b/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline @@ -24,10 +24,12 @@ namespace Google\Tests\Example\Library\V1; use Google\Example\Library\V1\LibraryServiceClient; +use \Google\GAX\ApiException; use \Google\GAX\GrpcCredentialsHelper; use \Google\GAX\LongRunning\OperationsClient; use \Google\GAX\Testing\LongRunning\MockOperationsImpl; use \Google\GAX\Testing\MockStubTrait; +use \Grpc; use \PHPUnit_Framework_TestCase; use \google\example\library\v1\AddCommentsRequest; use \google\example\library\v1\Book; @@ -74,6 +76,7 @@ use \google\tagger\v1\AddLabelResponse; use \google\tagger\v1\AddTagRequest; use \google\tagger\v1\AddTagResponse; use \google\tagger\v1\LabelerGrpcClient; +use \stdClass; /** * @group library @@ -153,6 +156,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function createShelfExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $shelf = new Shelf(); + + try { + $client->createShelf($shelf); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -191,6 +224,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function getShelfExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + $options = "options-1249474914"; + + try { + $client->getShelf($formattedName, $options); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -227,6 +291,33 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function listShelvesExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + try { + $client->listShelves(); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -237,8 +328,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); - // Add empty response to the grpc stub - $grpcStub->addResponse(new EmptyC()); + // Mock response + $expectedResponse = new EmptyC(); + $grpcStub->addResponse($expectedResponse); + // Mock request $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); @@ -254,6 +347,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function deleteShelfExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + + try { + $client->deleteShelf($formattedName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -292,6 +415,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function mergeShelvesExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + $formattedOtherShelfName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + + try { + $client->mergeShelves($formattedName, $formattedOtherShelfName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -332,6 +486,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function createBookExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + $book = new Book(); + + try { + $client->createBook($formattedName, $book); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -373,6 +558,40 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function publishSeriesExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $shelf = new Shelf(); + $books = []; + $seriesString = "foobar"; + $seriesUuid = new SeriesUuid(); + $seriesUuid->setSeriesString($seriesString); + + try { + $client->publishSeries($shelf, $books, $seriesUuid); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -411,6 +630,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function getBookExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + + try { + $client->getBook($formattedName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -451,6 +700,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function listBooksExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + + try { + $client->listBooks($formattedName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -461,8 +740,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); - // Add empty response to the grpc stub - $grpcStub->addResponse(new EmptyC()); + // Mock response + $expectedResponse = new EmptyC(); + $grpcStub->addResponse($expectedResponse); + // Mock request $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); @@ -478,6 +759,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function deleteBookExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + + try { + $client->deleteBook($formattedName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -518,6 +829,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function updateBookExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $book = new Book(); + + try { + $client->updateBook($formattedName, $book); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -558,6 +900,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function moveBookExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $formattedOtherShelfName = LibraryServiceClient::formatShelfName("[SHELF_ID]"); + + try { + $client->moveBook($formattedName, $formattedOtherShelfName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -594,6 +967,33 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function listStringsExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + try { + $client->listStrings(); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -604,8 +1004,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); - // Add empty response to the grpc stub - $grpcStub->addResponse(new EmptyC()); + // Mock response + $expectedResponse = new EmptyC(); + $grpcStub->addResponse($expectedResponse); + // Mock request $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); $comment = "95"; @@ -633,21 +1035,59 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase /** * @test */ - public function getBookFromArchiveTest() + public function addCommentsExceptionTest() { $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); $this->assertTrue($grpcStub->isExhausted()); - // Mock response - $name2 = "name2-1052831874"; - $author = "author-1406328437"; - $title = "title110371416"; - $read = true; - $expectedResponse = new BookFromArchive(); - $expectedResponse->setName($name2); - $expectedResponse->setAuthor($author); + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $comment = "95"; + $stage = Stage::UNSET; + $alignment = Alignment::CHAR; + $commentsElement = new Comment(); + $commentsElement->setComment($comment); + $commentsElement->setStage($stage); + $commentsElement->setAlignment($alignment); + $comments = [$commentsElement]; + + try { + $client->addComments($formattedName, $comments); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + + /** + * @test + */ + public function getBookFromArchiveTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + // Mock response + $name2 = "name2-1052831874"; + $author = "author-1406328437"; + $title = "title110371416"; + $read = true; + $expectedResponse = new BookFromArchive(); + $expectedResponse->setName($name2); + $expectedResponse->setAuthor($author); $expectedResponse->setTitle($title); $expectedResponse->setRead($read); $grpcStub->addResponse($expectedResponse); @@ -668,6 +1108,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function getBookFromArchiveExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatArchivedBookName("[ARCHIVE_PATH]", "[BOOK_ID]"); + + try { + $client->getBookFromArchive($formattedName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -708,6 +1178,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function getBookFromAnywhereExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $formattedAltBookName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + + try { + $client->getBookFromAnywhere($formattedName, $formattedAltBookName); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -718,8 +1219,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); - // Add empty response to the grpc stub - $grpcStub->addResponse(new EmptyC()); + // Mock response + $expectedResponse = new EmptyC(); + $grpcStub->addResponse($expectedResponse); + // Mock request $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); $indexName = "default index"; @@ -740,6 +1243,39 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function updateBookIndexExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $indexName = "default index"; + $indexMapItem = "indexMapItem1918721251"; + $indexMap = ["default_key" => $indexMapItem,]; + + try { + $client->updateBookIndex($formattedName, $indexName, $indexMap); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -783,6 +1319,38 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function findRelatedBooksExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $namesElement = "namesElement-249113339"; + $names = [$namesElement]; + $shelves = []; + + try { + $client->findRelatedBooks($names, $shelves); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -815,6 +1383,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function addTagExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedResource = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $tag = "tag114586"; + + try { + $client->addTag($formattedResource, $tag); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -847,6 +1446,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function addLabelExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLabelerImpl']); + $client = $this->createClient('createLabelerStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $formattedResource = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + $label = "label102727412"; + + try { + $client->addLabel($formattedResource, $label); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + /** * @test */ @@ -923,6 +1553,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($operationsStub->isExhausted()); } + /** + * @test + */ + public function getBigBookExceptionTest() + { + $operationsStub = $this->createStub([$this, 'createMockOperationsStub']); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'scopes' => [], + 'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) { + return $operationsStub; + } + ]); + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub, [ + 'operationsClient' => $operationsClient + ]); + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/getBigBookTest')->setDone(false); + $grpcStub->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $operationsStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + + $response = $client->getBigBook($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/getBigBookTest'); + + try { + $response->pollUntilComplete(); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + } + /** * @test */ @@ -991,6 +1675,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($operationsStub->isExhausted()); } + /** + * @test + */ + public function getBigNothingExceptionTest() + { + $operationsStub = $this->createStub([$this, 'createMockOperationsStub']); + $operationsClient = new OperationsClient([ + 'serviceAddress' => '', + 'scopes' => [], + 'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) { + return $operationsStub; + } + ]); + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub, [ + 'operationsClient' => $operationsClient + ]); + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/getBigNothingTest')->setDone(false); + $grpcStub->addResponse($incompleteOperation); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $operationsStub->addResponse(null, $status); + + // Mock request + $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]"); + + $response = $client->getBigNothing($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/getBigNothingTest'); + + try { + $response->pollUntilComplete(); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + $this->assertTrue($operationsStub->isExhausted()); + } + /** * @test */ @@ -1073,4 +1811,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase $this->assertTrue($grpcStub->isExhausted()); } + /** + * @test + */ + public function testOptionalRequiredFlatteningParamsExceptionTest() + { + $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']); + $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub); + + $this->assertTrue($grpcStub->isExhausted()); + + $status = new stdClass(); + $status->code = Grpc\STATUS_INTERNAL; + $status->details = 'internal error'; + $grpcStub->addResponse(null, $status); + + // Mock request + $requiredSingularInt32 = -72313594; + $requiredSingularInt64 = -72313499; + $requiredSingularFloat = -7514705.0; + $requiredSingularDouble = 1.9111005E8; + $requiredSingularBool = true; + $requiredSingularEnum = InnerEnum::ZERO; + $requiredSingularString = "requiredSingularString-1949894503"; + $requiredSingularBytes = "-29"; + $requiredSingularMessage = new InnerMessage(); + $requiredSingularResourceName = "requiredSingularResourceName-1701575020"; + $requiredSingularResourceNameOneof = "requiredSingularResourceNameOneof-25303726"; + $requiredSingularFixed32 = 720656715; + $requiredSingularFixed64 = 720656810; + $requiredRepeatedInt32 = []; + $requiredRepeatedInt64 = []; + $requiredRepeatedFloat = []; + $requiredRepeatedDouble = []; + $requiredRepeatedBool = []; + $requiredRepeatedEnum = []; + $requiredRepeatedString = []; + $requiredRepeatedBytes = []; + $requiredRepeatedMessage = []; + $formattedRequiredRepeatedResourceName = []; + $formattedRequiredRepeatedResourceNameOneof = []; + $requiredRepeatedFixed32 = []; + $requiredRepeatedFixed64 = []; + $requiredMap = []; + + try { + $client->testOptionalRequiredFlatteningParams($requiredSingularInt32, $requiredSingularInt64, $requiredSingularFloat, $requiredSingularDouble, $requiredSingularBool, $requiredSingularEnum, $requiredSingularString, $requiredSingularBytes, $requiredSingularMessage, $requiredSingularResourceName, $requiredSingularResourceNameOneof, $requiredSingularFixed32, $requiredSingularFixed64, $requiredRepeatedInt32, $requiredRepeatedInt64, $requiredRepeatedFloat, $requiredRepeatedDouble, $requiredRepeatedBool, $requiredRepeatedEnum, $requiredRepeatedString, $requiredRepeatedBytes, $requiredRepeatedMessage, $formattedRequiredRepeatedResourceName, $formattedRequiredRepeatedResourceNameOneof, $requiredRepeatedFixed32, $requiredRepeatedFixed64, $requiredMap); + // If the $client method call did not throw, fail the test + $this->fail("Expected an ApiException, but no exception was thrown."); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($status->details, $ex->getMessage()); + } + + $this->assertTrue($grpcStub->isExhausted()); + } + }