From 91e8c5be1c653aea271186b788d5ca3e4f0c8d65 Mon Sep 17 00:00:00 2001 From: Rene Reimann Date: Mon, 8 Jun 2026 12:29:58 +0200 Subject: [PATCH 1/3] maintenance - add ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT - prevent stop to eraly local test runner --- src/HTTPClient.php | 22 +++++++++++++------ .../Resource/AbstractBaseTest.php | 6 +++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/HTTPClient.php b/src/HTTPClient.php index ea8f602..a6a1d78 100644 --- a/src/HTTPClient.php +++ b/src/HTTPClient.php @@ -134,14 +134,22 @@ public function __construct( array $options = [] ) $verifySsl = $options['verify']; } + // Optional: pass additional Guzzle options (e.g. headers, curl options) + $connection_options = []; + if (array_key_exists('connection_options', $options) && is_array($options['connection_options'])) { + $connection_options = $options['connection_options']; + } + // Execute constructor of base class - parent::__construct([ - 'base_uri' => $this->base_url, - 'timeout' => $timeout, - 'connect_timeout' => $timeout, - 'debug' => $debug, - 'verify' => $verifySsl, - ]); + parent::__construct( + [ + 'base_uri' => $this->base_url, + 'timeout' => $timeout, + 'connect_timeout' => $timeout, + 'debug' => $debug, + 'verify' => $verifySsl, + ] + $connection_options + ); } /** diff --git a/test/ZammadAPIClient/Resource/AbstractBaseTest.php b/test/ZammadAPIClient/Resource/AbstractBaseTest.php index 7f1d554..791143b 100644 --- a/test/ZammadAPIClient/Resource/AbstractBaseTest.php +++ b/test/ZammadAPIClient/Resource/AbstractBaseTest.php @@ -17,10 +17,12 @@ abstract class AbstractBaseTest extends TestCase public static function setUpBeforeClass(): void { + $client_timeout = getenv('ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT'); + $client_config = [ - # Set a high timeout for tests to work with slow CI. - 'timeout' => 30, + 'timeout' => !empty($client_timeout) ? $client_timeout : 30, 'debug' => getenv('ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_DEBUG'), + 'connection_options' => ['headers' => ['Connection' => 'close']], ]; $env_keys = [ From 8a7cf8438b4e1bfb2ebefc43f6b4a9a85214cfa8 Mon Sep 17 00:00:00 2001 From: Rene Reimann Date: Mon, 8 Jun 2026 13:27:25 +0200 Subject: [PATCH 2/3] maintenance - update readme --- README.md | 22 ++++++++++++++++++++++ phpunit.xml.dist | 1 + 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index fd132e7..7684480 100644 --- a/README.md +++ b/README.md @@ -326,6 +326,7 @@ $client->resource( ResourceType::TICKET ); | TAG|✔|–|✔|–|–|✔|✔|–| | LINK|✔|–|–|–|–|✔|✔|–| + ## Publishing 1. Add release to [CHANGELOG.md](CHANGELOG.md) @@ -335,3 +336,24 @@ $client->resource( ResourceType::TICKET ); ## Contributing Bug reports and pull requests are welcome on [GitHub](https://github.com/zammad/zammad-api-client-php). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. + +### Running tests + +Tests require a running Zammad instance with API access enabled. Set the following environment variables: + +| Variable | Required | Default | Description | +|---|---|---|---| +| `ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL` | Yes | — | URL to Zammad (e.g. `http://localhost:3000/`) | +| `ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME` | Yes | — | Username for authentication | +| `ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD` | Yes | — | Password for authentication | +| `ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT` | No | `30` | Request timeout in seconds | + +**Note:** Only username/password authentication is supported for tests. + +```bash +ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL="http://localhost:3000/" \ +ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME="admin@example.com" \ +ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD="test" \ +ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT=120 \ +vendor/bin/phpunit +``` diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8ba564e..2cd5e9e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -21,6 +21,7 @@ + --> From 1140d90b7f7327b5bf22c496d1f89f3c48c8a6e3 Mon Sep 17 00:00:00 2001 From: Rene Reimann Date: Mon, 8 Jun 2026 13:44:29 +0200 Subject: [PATCH 3/3] maintenance - code style: array key validation --- src/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTPClient.php b/src/HTTPClient.php index a6a1d78..08531a7 100644 --- a/src/HTTPClient.php +++ b/src/HTTPClient.php @@ -136,7 +136,7 @@ public function __construct( array $options = [] ) // Optional: pass additional Guzzle options (e.g. headers, curl options) $connection_options = []; - if (array_key_exists('connection_options', $options) && is_array($options['connection_options'])) { + if (is_array($options['connection_options'] ?? null)) { $connection_options = $options['connection_options']; }