8declare(strict_types=1);
9require dirname(__DIR__).
'/src/LGV_TZ_Lookup_Test.php';
10require dirname(__DIR__).
'/src/TestLocations.php';
13 $expectedLookups[$case[
'params'][
'lng'].
','.$case[
'params'][
'lat']] = $case[
'result'];
22 parse_str($query, $arguments);
23 if (($arguments[
'secret'] ??
'') !==
'fixture-secret') {
throw new RuntimeException(
'Test requests lost their configured secret.'); }
32 if (!$value) {
throw new RuntimeException($label); }
36foreach ([
'Lookups measured: 20',
'Total test time: 1.000 s',
'Average lookup: 10.500 ms',
37 'Median lookup: 10.500 ms',
'95th-percentile lookup: 19.000 ms',
'Slowest lookup: 20.000 ms',
38 'PHP request peak memory: 8.00 MiB'] as $text) {
43$config = tempnam(sys_get_temp_dir(),
'lgv-tz-report-');
44file_put_contents(
$config,
'<?php $g_server_secret = "fixture-secret";');
49 reportCheck(str_contains($html,
$forceFailure ?
'1 Test Failures!' :
'All Tests (200) Passed!'),
'Location results are retained.');
50 reportCheck(substr_count($html,
'Lookup time: ') === 200,
'Each location reports elapsed time.');
51 reportCheck(str_contains($html,
'Lookups measured: 200'),
'Summary measures every result, including failures.');
52 reportCheck(preg_match(
'/Total test time: [0-9]+\.[0-9]{3} s/', $html) === 1,
'Total time is reported in seconds.');
53 reportCheck(str_contains($html,
'PHP request peak memory:'),
'Memory is reported.');
54 reportCheck(!str_contains($html,
'fixture-secret'),
'Report does not disclose the secret.');
55 echo
'Passed '.$checks.
' server report checks'.(
$forceFailure ?
' with a failing location' :
'').
".\n";
test_server_performance(array $nanoseconds, int|float $elapsed, int $peakMemory)
Summarize request lookup timings and the PHP request's peak memory.
$test_locations_param_array
This file has a list of long/lat pairs, along with the expected results, when presented to the server...
if(!is_file($autoload)) $checks
reportCheck(bool $value, string $label)
Assert one report property.
foreach($test_locations_param_array as $case) $forceFailure
call_server( $inQuery, $inIsCLI)