70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/Api/ApiCleanup.php';
|
|
require_once __DIR__ . '/Api/ApiResponse.php';
|
|
require_once __DIR__ . '/Api/ApiClient.php';
|
|
require_once __DIR__ . '/Api/ApiServer.php';
|
|
require_once __DIR__ . '/Api/ApiSchemaBootstrap.php';
|
|
require_once __DIR__ . '/Api/ApiFixtures.php';
|
|
require_once __DIR__ . '/Api/ApiTestRuntime.php';
|
|
|
|
use Tests\Support\Api\ApiClient;
|
|
use Tests\Support\Api\ApiFixtures;
|
|
use Tests\Support\Api\ApiResponse;
|
|
use Tests\Support\Api\ApiTestRuntime;
|
|
|
|
function api_tests_enabled(): bool
|
|
{
|
|
return getenv('RUN_API_TESTS') === '1';
|
|
}
|
|
|
|
function api_test_runtime(): ApiTestRuntime
|
|
{
|
|
return ApiTestRuntime::instance();
|
|
}
|
|
|
|
function api_client(): ApiClient
|
|
{
|
|
return api_test_runtime()->client();
|
|
}
|
|
|
|
function api_fixtures(): ApiFixtures
|
|
{
|
|
return api_test_runtime()->fixtures();
|
|
}
|
|
|
|
function usesApiSuite(): void
|
|
{
|
|
// The API lifecycle is bound via Tests\Support\Api\ApiTestCase in tests/Pest.php.
|
|
}
|
|
|
|
function api_test_covers(string $operation, string $kind = 'happy'): bool
|
|
{
|
|
return $operation !== '' && $kind !== '';
|
|
}
|
|
|
|
function assert_api_envelope(ApiResponse $response): ApiResponse
|
|
{
|
|
return $response->assertEnvelope();
|
|
}
|
|
|
|
function edge_test_broker_secret(): string
|
|
{
|
|
$secret = trim((string)(getenv('EDGE_BROKER_SHARED_SECRET') ?: ''));
|
|
|
|
return $secret !== '' ? $secret : 'truckwash-edge-test-secret';
|
|
}
|
|
|
|
/**
|
|
* @param array<string, string> $extraHeaders
|
|
* @return array<string, string>
|
|
*/
|
|
function edge_test_broker_headers(array $extraHeaders = []): array
|
|
{
|
|
return array_merge([
|
|
'X-Edge-Broker-Secret' => edge_test_broker_secret(),
|
|
], $extraHeaders);
|
|
}
|