Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ be found for Mac or Windows.
> vendor/bin/phpunit
```

For Showcase Conformance testing and client generation, see [tests/Conformance/README.md](tests/Conformance/README.md).

4. Run static analysis tools

```sh
Expand Down
46 changes: 46 additions & 0 deletions Gax/tests/Conformance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# GAX Showcase Conformance Testing

This directory contains the integration conformance test suite (`ShowcaseTest.php`) and generated client SDK for `gapic-showcase`.

## Prerequisites

- **Protobuf Compiler (`protoc`)**: Ensure `protoc` is installed and available in your `$PATH`.
- **Dev Dependencies**: Ensure dev dependencies are installed:
```sh
composer install -d dev/
```

## Generating the Showcase Client

To generate or update the Showcase client SDK, message classes, and metadata using the PHP CLI tool:

```sh
# From the repository root, run the console command:
./dev/google-cloud showcase:generate
```

Options:
- `-o, --out-dir <dir>`: Output directory relative to repository root (defaults to `Gax`).
- `-p, --showcase-path <dir>`: Path to local `gapic-showcase` repository (defaults to installed vendor dependency).
- `-g, --generator-path <dir>`: Path to local `gapic-generator-php` (defaults to installed vendor dependency).
- `-a, --googleapis-path <dir>`: Path to `googleapis` repository (defaults to submodule in `gapic-generator-php`).

## Running Conformance Tests

1. Install and launch the matching `gapic-showcase` mock server in the background:
```sh
# Option 1 (curl)
curl -L https://github.com/googleapis/gapic-showcase/releases/download/v0.41.1/gapic-showcase-0.41.1-linux-amd64.tar.gz | tar -zx
Comment thread
cy-yun marked this conversation as resolved.
./gapic-showcase run &

# Option 2 (go install)
go install github.com/googleapis/gapic-showcase/cmd/gapic-showcase@latest
gapic-showcase run &
```

2. Run the PHPUnit conformance test suite:
```sh
vendor/bin/phpunit -c Gax/phpunit-conformance.xml.dist
# or from the Gax directory:
cd Gax && vendor/bin/phpunit tests/Conformance/ShowcaseTest.php
```
Binary file modified Gax/tests/Conformance/metadata/V1Beta1/Compliance.php
Binary file not shown.
Binary file modified Gax/tests/Conformance/metadata/V1Beta1/Identity.php
Binary file not shown.
Binary file modified Gax/tests/Conformance/metadata/V1Beta1/Messaging.php
Binary file not shown.
Binary file modified Gax/tests/Conformance/metadata/V1Beta1/PBEcho.php
Binary file not shown.
28 changes: 14 additions & 14 deletions Gax/tests/Conformance/metadata/V1Beta1/Sequence.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 2 additions & 13 deletions Gax/tests/Conformance/src/V1beta1/AttemptSequenceRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 27 additions & 37 deletions Gax/tests/Conformance/src/V1beta1/Client/ComplianceClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright 2025 Google LLC
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
use Google\ApiCore\ApiException;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\Options\ClientOptions;
use Google\ApiCore\RetrySettings;
use Google\ApiCore\Transport\TransportInterface;
use Google\ApiCore\ValidationException;
Expand Down Expand Up @@ -77,7 +78,11 @@ final class ComplianceClient
/** The name of the code generator, to be included in the agent header. */
private const CODEGEN_NAME = 'gapic';

/** The default scopes required by the service. */
/**
* The default scopes required by the service.
*
* @internal
*/
public static $serviceScopes = [];

private static function getClientDefaults()
Expand All @@ -102,25 +107,28 @@ private static function getClientDefaults()
/**
* Constructor.
*
* @param array $options {
* @param array|ClientOptions $options {
* Optional. Options for configuring the service API wrapper.
*
* @type string $apiEndpoint
* The address of the API remote host. May optionally include the port, formatted
* as "<uri>:<port>". Default 'localhost:7469:443'.
* @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
* The credentials to be used by the client to authorize API calls. This option
* accepts either a path to a credentials file, or a decoded credentials file as a
* PHP array.
* *Advanced usage*: In addition, this option can also accept a pre-constructed
* {@see \Google\Auth\FetchAuthTokenInterface} object or
* {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
* objects are provided, any settings in $credentialsConfig will be ignored.
* *Important*: If you accept a credential configuration (credential
* JSON/File/Stream) from an external source for authentication to Google Cloud
* Platform, you must validate it before providing it to any Google API or library.
* Providing an unvalidated credential configuration to Google APIs can compromise
* the security of your systems and data. For more information {@see
* @type FetchAuthTokenInterface|CredentialsWrapper $credentials
* This option should only be used with a pre-constructed
* {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
* when one of these objects are provided, any settings in $credentialsConfig will
* be ignored.
* **Important**: If you are providing a path to a credentials file, or a decoded
* credentials file as a PHP array, this usage is now DEPRECATED. Providing an
* unvalidated credential configuration to Google APIs can compromise the security
* of your systems and data. It is recommended to create the credentials explicitly
* ```
* use Google\Auth\Credentials\ServiceAccountCredentials;
* use Google\Showcase\V1beta1\ComplianceClient;
* $creds = new ServiceAccountCredentials($scopes, $json);
* $options = new ComplianceClient(['credentials' => $creds]);
* ```
* {@see
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
* @type array $credentialsConfig
* Options used to configure credentials, including auth token caching, for the
Expand Down Expand Up @@ -158,13 +166,15 @@ private static function getClientDefaults()
* @type false|LoggerInterface $logger
* A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
* 'GOOGLE_SDK_PHP_LOGGING' environment flag
* @type string $universeDomain
* The service domain for the client. Defaults to 'googleapis.com'.
* }
*
* @throws ValidationException
*
* @experimental
*/
public function __construct(array $options = [])
public function __construct(array|ClientOptions $options = [])
{
$clientOptions = $this->buildClientOptions($options);
$this->setClientOptions($clientOptions);
Expand All @@ -191,8 +201,6 @@ public function __call($method, $args)
*
* The async variant is {@see ComplianceClient::getEnumAsync()} .
*
* @example samples/V1beta1/ComplianceClient/get_enum.php
*
* @param EnumRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -220,8 +228,6 @@ public function getEnum(EnumRequest $request, array $callOptions = []): EnumResp
*
* The async variant is {@see ComplianceClient::repeatDataBodyAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_body.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -250,8 +256,6 @@ public function repeatDataBody(RepeatRequest $request, array $callOptions = []):
*
* The async variant is {@see ComplianceClient::repeatDataBodyInfoAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_body_info.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand All @@ -278,8 +282,6 @@ public function repeatDataBodyInfo(RepeatRequest $request, array $callOptions =
*
* The async variant is {@see ComplianceClient::repeatDataBodyPatchAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_body_patch.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand All @@ -306,8 +308,6 @@ public function repeatDataBodyPatch(RepeatRequest $request, array $callOptions =
*
* The async variant is {@see ComplianceClient::repeatDataBodyPutAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_body_put.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand All @@ -334,8 +334,6 @@ public function repeatDataBodyPut(RepeatRequest $request, array $callOptions = [
*
* The async variant is {@see ComplianceClient::repeatDataPathResourceAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_path_resource.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -363,8 +361,6 @@ public function repeatDataPathResource(RepeatRequest $request, array $callOption
* The async variant is
* {@see ComplianceClient::repeatDataPathTrailingResourceAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_path_trailing_resource.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -392,8 +388,6 @@ public function repeatDataPathTrailingResource(RepeatRequest $request, array $ca
*
* The async variant is {@see ComplianceClient::repeatDataQueryAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_query.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -422,8 +416,6 @@ public function repeatDataQuery(RepeatRequest $request, array $callOptions = [])
*
* The async variant is {@see ComplianceClient::repeatDataSimplePathAsync()} .
*
* @example samples/V1beta1/ComplianceClient/repeat_data_simple_path.php
*
* @param RepeatRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down Expand Up @@ -455,8 +447,6 @@ public function repeatDataSimplePath(RepeatRequest $request, array $callOptions
*
* The async variant is {@see ComplianceClient::verifyEnumAsync()} .
*
* @example samples/V1beta1/ComplianceClient/verify_enum.php
*
* @param EnumResponse $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
Expand Down
Loading
Loading