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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ $client->resource( ResourceType::TICKET );
| TAG|✔|–|✔|–|–|✔|✔|–|
| LINK|✔|–|–|–|–|✔|✔|–|


## Publishing

1. Add release to [CHANGELOG.md](CHANGELOG.md)
Expand All @@ -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
```
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<env name="ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL" value="https://...." />
<env name="ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME" value="..." />
<env name="ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD" value="..." />
<env name="ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT" value="30" />
-->
</php>
</phpunit>
22 changes: 15 additions & 7 deletions src/HTTPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (is_array($options['connection_options'] ?? null)) {
$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
);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions test/ZammadAPIClient/Resource/AbstractBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down