diff --git a/ShoppingMerchantInventories/owlbot.py b/ShoppingMerchantInventories/owlbot.py index 2f36f2715cc4..267742791fca 100644 --- a/ShoppingMerchantInventories/owlbot.py +++ b/ShoppingMerchantInventories/owlbot.py @@ -47,7 +47,7 @@ '--package=@prettier/plugin-php@^0.19', '--', 'prettier', - '**/Gapic/*', + '**/Client/*', '--write', '--parser=php', '--single-quote', diff --git a/ShoppingMerchantInventories/src/V1/Client/LocalInventoryServiceClient.php b/ShoppingMerchantInventories/src/V1/Client/LocalInventoryServiceClient.php index 0e7c1650838a..3b6a3f57ab53 100644 --- a/ShoppingMerchantInventories/src/V1/Client/LocalInventoryServiceClient.php +++ b/ShoppingMerchantInventories/src/V1/Client/LocalInventoryServiceClient.php @@ -85,9 +85,7 @@ final class LocalInventoryServiceClient * * @internal */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/content', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/content']; private static function getClientDefaults() { @@ -345,8 +343,10 @@ public function insertLocalInventory(InsertLocalInventoryRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function listLocalInventories(ListLocalInventoriesRequest $request, array $callOptions = []): PagedListResponse - { + public function listLocalInventories( + ListLocalInventoriesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListLocalInventories', $request, $callOptions); } } diff --git a/ShoppingMerchantInventories/src/V1/Client/RegionalInventoryServiceClient.php b/ShoppingMerchantInventories/src/V1/Client/RegionalInventoryServiceClient.php index 6c3083790896..39468afbcf89 100644 --- a/ShoppingMerchantInventories/src/V1/Client/RegionalInventoryServiceClient.php +++ b/ShoppingMerchantInventories/src/V1/Client/RegionalInventoryServiceClient.php @@ -86,9 +86,7 @@ final class RegionalInventoryServiceClient * * @internal */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/content', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/content']; private static function getClientDefaults() { @@ -103,7 +101,8 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/regional_inventory_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/regional_inventory_service_rest_client_config.php', ], ], ]; @@ -314,8 +313,10 @@ public function deleteRegionalInventory(DeleteRegionalInventoryRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function insertRegionalInventory(InsertRegionalInventoryRequest $request, array $callOptions = []): RegionalInventory - { + public function insertRegionalInventory( + InsertRegionalInventoryRequest $request, + array $callOptions = [] + ): RegionalInventory { return $this->startApiCall('InsertRegionalInventory', $request, $callOptions)->wait(); } @@ -346,8 +347,10 @@ public function insertRegionalInventory(InsertRegionalInventoryRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function listRegionalInventories(ListRegionalInventoriesRequest $request, array $callOptions = []): PagedListResponse - { + public function listRegionalInventories( + ListRegionalInventoriesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListRegionalInventories', $request, $callOptions); } } diff --git a/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php b/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php index 0210e97e2809..453edcaa871e 100644 --- a/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php +++ b/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php @@ -89,9 +89,7 @@ final class LocalInventoryServiceClient * * @internal */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/content', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/content']; private static function getClientDefaults() { @@ -363,8 +361,10 @@ public function insertLocalInventory(InsertLocalInventoryRequest $request, array * * @experimental */ - public function listLocalInventories(ListLocalInventoriesRequest $request, array $callOptions = []): PagedListResponse - { + public function listLocalInventories( + ListLocalInventoriesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListLocalInventories', $request, $callOptions); } } diff --git a/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php b/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php index bd65602a91b9..4cd6ebbcf719 100644 --- a/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php +++ b/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php @@ -90,9 +90,7 @@ final class RegionalInventoryServiceClient * * @internal */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/content', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/content']; private static function getClientDefaults() { @@ -107,7 +105,8 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/regional_inventory_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/regional_inventory_service_rest_client_config.php', ], ], ]; @@ -330,8 +329,10 @@ public function deleteRegionalInventory(DeleteRegionalInventoryRequest $request, * * @experimental */ - public function insertRegionalInventory(InsertRegionalInventoryRequest $request, array $callOptions = []): RegionalInventory - { + public function insertRegionalInventory( + InsertRegionalInventoryRequest $request, + array $callOptions = [] + ): RegionalInventory { return $this->startApiCall('InsertRegionalInventory', $request, $callOptions)->wait(); } @@ -364,8 +365,10 @@ public function insertRegionalInventory(InsertRegionalInventoryRequest $request, * * @experimental */ - public function listRegionalInventories(ListRegionalInventoriesRequest $request, array $callOptions = []): PagedListResponse - { + public function listRegionalInventories( + ListRegionalInventoriesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListRegionalInventories', $request, $callOptions); } } diff --git a/ShoppingMerchantInventories/tests/Unit/V1/Client/LocalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1/Client/LocalInventoryServiceClientTest.php index f81c50357c29..d7f8e3e9bfeb 100644 --- a/ShoppingMerchantInventories/tests/Unit/V1/Client/LocalInventoryServiceClientTest.php +++ b/ShoppingMerchantInventories/tests/Unit/V1/Client/LocalInventoryServiceClientTest.php @@ -52,7 +52,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return LocalInventoryServiceClient */ @@ -77,14 +79,16 @@ public function deleteLocalInventoryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); $gapicClient->deleteLocalInventory($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.LocalInventoryService/DeleteLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -101,17 +105,19 @@ public function deleteLocalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); try { $gapicClient->deleteLocalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -149,16 +155,17 @@ public function insertLocalInventoryTest() $localInventory = new LocalInventory(); $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; $localInventory->setStoreCode($localInventoryStoreCode); - $request = (new InsertLocalInventoryRequest()) - ->setParent($formattedParent) - ->setLocalInventory($localInventory); + $request = (new InsertLocalInventoryRequest())->setParent($formattedParent)->setLocalInventory($localInventory); $response = $gapicClient->insertLocalInventory($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.LocalInventoryService/InsertLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.LocalInventoryService/InsertLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getLocalInventory(); @@ -177,21 +184,22 @@ public function insertLocalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); $localInventory = new LocalInventory(); $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; $localInventory->setStoreCode($localInventoryStoreCode); - $request = (new InsertLocalInventoryRequest()) - ->setParent($formattedParent) - ->setLocalInventory($localInventory); + $request = (new InsertLocalInventoryRequest())->setParent($formattedParent)->setLocalInventory($localInventory); try { $gapicClient->insertLocalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -216,17 +224,14 @@ public function listLocalInventoriesTest() // Mock response $nextPageToken = ''; $localInventoriesElement = new LocalInventory(); - $localInventories = [ - $localInventoriesElement, - ]; + $localInventories = [$localInventoriesElement]; $expectedResponse = new ListLocalInventoriesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocalInventories($localInventories); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListLocalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListLocalInventoriesRequest())->setParent($formattedParent); $response = $gapicClient->listLocalInventories($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -236,7 +241,10 @@ public function listLocalInventoriesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.LocalInventoryService/ListLocalInventories', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.LocalInventoryService/ListLocalInventories', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -253,17 +261,19 @@ public function listLocalInventoriesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListLocalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListLocalInventoriesRequest())->setParent($formattedParent); try { $gapicClient->listLocalInventories($request); // If the $gapicClient method call did not throw, fail the test @@ -290,14 +300,16 @@ public function deleteLocalInventoryAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); $gapicClient->deleteLocalInventoryAsync($request)->wait(); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.LocalInventoryService/DeleteLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); diff --git a/ShoppingMerchantInventories/tests/Unit/V1/Client/RegionalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1/Client/RegionalInventoryServiceClientTest.php index 0980e0929f26..2003608e256c 100644 --- a/ShoppingMerchantInventories/tests/Unit/V1/Client/RegionalInventoryServiceClientTest.php +++ b/ShoppingMerchantInventories/tests/Unit/V1/Client/RegionalInventoryServiceClientTest.php @@ -52,7 +52,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return RegionalInventoryServiceClient */ @@ -77,14 +79,16 @@ public function deleteRegionalInventoryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); $gapicClient->deleteRegionalInventory($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.RegionalInventoryService/DeleteRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -101,17 +105,19 @@ public function deleteRegionalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); try { $gapicClient->deleteRegionalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -158,7 +164,10 @@ public function insertRegionalInventoryTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.RegionalInventoryService/InsertRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.RegionalInventoryService/InsertRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getRegionalInventory(); @@ -177,12 +186,15 @@ public function insertRegionalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); @@ -216,17 +228,14 @@ public function listRegionalInventoriesTest() // Mock response $nextPageToken = ''; $regionalInventoriesElement = new RegionalInventory(); - $regionalInventories = [ - $regionalInventoriesElement, - ]; + $regionalInventories = [$regionalInventoriesElement]; $expectedResponse = new ListRegionalInventoriesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setRegionalInventories($regionalInventories); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListRegionalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListRegionalInventoriesRequest())->setParent($formattedParent); $response = $gapicClient->listRegionalInventories($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -236,7 +245,10 @@ public function listRegionalInventoriesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.RegionalInventoryService/ListRegionalInventories', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.RegionalInventoryService/ListRegionalInventories', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -253,17 +265,19 @@ public function listRegionalInventoriesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListRegionalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListRegionalInventoriesRequest())->setParent($formattedParent); try { $gapicClient->listRegionalInventories($request); // If the $gapicClient method call did not throw, fail the test @@ -290,14 +304,16 @@ public function deleteRegionalInventoryAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); $gapicClient->deleteRegionalInventoryAsync($request)->wait(); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1.RegionalInventoryService/DeleteRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); diff --git a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php index b0eeb897b607..5e469bf442cc 100644 --- a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php +++ b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php @@ -52,7 +52,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return LocalInventoryServiceClient */ @@ -77,14 +79,16 @@ public function deleteLocalInventoryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); $gapicClient->deleteLocalInventory($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -101,17 +105,19 @@ public function deleteLocalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); try { $gapicClient->deleteLocalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -157,16 +163,17 @@ public function insertLocalInventoryTest() $localInventory = new LocalInventory(); $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; $localInventory->setStoreCode($localInventoryStoreCode); - $request = (new InsertLocalInventoryRequest()) - ->setParent($formattedParent) - ->setLocalInventory($localInventory); + $request = (new InsertLocalInventoryRequest())->setParent($formattedParent)->setLocalInventory($localInventory); $response = $gapicClient->insertLocalInventory($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/InsertLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.LocalInventoryService/InsertLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getLocalInventory(); @@ -185,21 +192,22 @@ public function insertLocalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); $localInventory = new LocalInventory(); $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; $localInventory->setStoreCode($localInventoryStoreCode); - $request = (new InsertLocalInventoryRequest()) - ->setParent($formattedParent) - ->setLocalInventory($localInventory); + $request = (new InsertLocalInventoryRequest())->setParent($formattedParent)->setLocalInventory($localInventory); try { $gapicClient->insertLocalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -224,17 +232,14 @@ public function listLocalInventoriesTest() // Mock response $nextPageToken = ''; $localInventoriesElement = new LocalInventory(); - $localInventories = [ - $localInventoriesElement, - ]; + $localInventories = [$localInventoriesElement]; $expectedResponse = new ListLocalInventoriesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocalInventories($localInventories); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListLocalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListLocalInventoriesRequest())->setParent($formattedParent); $response = $gapicClient->listLocalInventories($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -244,7 +249,10 @@ public function listLocalInventoriesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/ListLocalInventories', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.LocalInventoryService/ListLocalInventories', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -261,17 +269,19 @@ public function listLocalInventoriesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListLocalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListLocalInventoriesRequest())->setParent($formattedParent); try { $gapicClient->listLocalInventories($request); // If the $gapicClient method call did not throw, fail the test @@ -298,14 +308,16 @@ public function deleteLocalInventoryAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); - $request = (new DeleteLocalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteLocalInventoryRequest())->setName($formattedName); $gapicClient->deleteLocalInventoryAsync($request)->wait(); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); diff --git a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php index e615063ee973..beb39f0bd0bc 100644 --- a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php +++ b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php @@ -52,7 +52,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return RegionalInventoryServiceClient */ @@ -77,14 +79,16 @@ public function deleteRegionalInventoryTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); $gapicClient->deleteRegionalInventory($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -101,17 +105,19 @@ public function deleteRegionalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); try { $gapicClient->deleteRegionalInventory($request); // If the $gapicClient method call did not throw, fail the test @@ -158,7 +164,10 @@ public function insertRegionalInventoryTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/InsertRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/InsertRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getRegionalInventory(); @@ -177,12 +186,15 @@ public function insertRegionalInventoryExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); @@ -216,17 +228,14 @@ public function listRegionalInventoriesTest() // Mock response $nextPageToken = ''; $regionalInventoriesElement = new RegionalInventory(); - $regionalInventories = [ - $regionalInventoriesElement, - ]; + $regionalInventories = [$regionalInventoriesElement]; $expectedResponse = new ListRegionalInventoriesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setRegionalInventories($regionalInventories); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListRegionalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListRegionalInventoriesRequest())->setParent($formattedParent); $response = $gapicClient->listRegionalInventories($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -236,7 +245,10 @@ public function listRegionalInventoriesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/ListRegionalInventories', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/ListRegionalInventories', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -253,17 +265,19 @@ public function listRegionalInventoriesExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->productName('[ACCOUNT]', '[PRODUCT]'); - $request = (new ListRegionalInventoriesRequest()) - ->setParent($formattedParent); + $request = (new ListRegionalInventoriesRequest())->setParent($formattedParent); try { $gapicClient->listRegionalInventories($request); // If the $gapicClient method call did not throw, fail the test @@ -290,14 +304,16 @@ public function deleteRegionalInventoryAsyncTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); - $request = (new DeleteRegionalInventoryRequest()) - ->setName($formattedName); + $request = (new DeleteRegionalInventoryRequest())->setName($formattedName); $gapicClient->deleteRegionalInventoryAsync($request)->wait(); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $this->assertSame( + '/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted());