Skip to content
Merged
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
27 changes: 12 additions & 15 deletions test/ZammadAPIClient/Resource/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,28 @@

use PHPUnit\Framework\TestCase;
use ZammadAPIClient\Client;
use ZammadAPIClient\EnvConfigTrait;
use ZammadAPIClient\ResourceType;

class LinkTest extends TestCase
{
use EnvConfigTrait;

private static $client;
private static $source_ticket;
private static $target_ticket;

public static function setUpBeforeClass(): void
{
$client_config = [];

$env_keys = [
'url' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL',
'username' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME',
'password' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD',
];
foreach ( $env_keys as $config_key => $env_key ) {
$value = getenv( $env_key );
if ( empty($value) ) {
throw new \RuntimeException("Missing environment variable $env_key");
}

$client_config[$config_key] = $value;
}
// This suite creates and deletes real tickets (with their articles, links,
// etc.) for every single test, which can occasionally take longer than the
// client's 5 second default timeout under load. Match AbstractBaseTest's
// more generous timeout to avoid spurious ConnectExceptions in tearDown().
$client_timeout = getenv('ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT');

$client_config = self::getZammadConfig([
'timeout' => !empty($client_timeout) ? $client_timeout : 30,
]);

self::$client = new Client($client_config);
}
Expand Down
27 changes: 12 additions & 15 deletions test/ZammadAPIClient/Resource/TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,29 @@

use PHPUnit\Framework\TestCase;
use ZammadAPIClient\Client;
use ZammadAPIClient\EnvConfigTrait;
use ZammadAPIClient\ResourceType;

class TagTest extends TestCase
{
use EnvConfigTrait;

private static $client;
private static $ticket;

protected $resource_type = ResourceType::TAG;

public static function setUpBeforeClass(): void
{
$client_config = [];

$env_keys = [
'url' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_URL',
'username' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_USERNAME',
'password' => 'ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_PASSWORD',
];
foreach ( $env_keys as $config_key => $env_key ) {
$value = getenv($env_key);
if ( empty($value) ) {
throw new \RuntimeException("Missing environment variable $env_key");
}

$client_config[$config_key] = $value;
}
// This suite creates and deletes a real ticket for every single test, which
// can occasionally take longer than the client's 5 second default timeout
// under load. Match AbstractBaseTest's more generous timeout to avoid
// spurious ConnectExceptions in tearDown().
$client_timeout = getenv('ZAMMAD_PHP_API_CLIENT_UNIT_TESTS_TIMEOUT');

$client_config = self::getZammadConfig([
'timeout' => !empty($client_timeout) ? $client_timeout : 30,
]);

self::$client = new Client($client_config);
}
Expand Down