added unit tests
This commit is contained in:
@ -20,8 +20,10 @@ $route = strtolower($route);
|
||||
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
qdb_api_log_begin($method, $route !== '' ? $route : '(root)');
|
||||
register_shutdown_function('qdb_api_log_finish');
|
||||
if (!defined('QDB_TESTING')) {
|
||||
qdb_api_log_begin($method, $route !== '' ? $route : '(root)');
|
||||
register_shutdown_function('qdb_api_log_finish');
|
||||
}
|
||||
|
||||
// CORS
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
@ -73,6 +75,13 @@ try {
|
||||
require $handlerFile;
|
||||
|
||||
} catch (Throwable $e) {
|
||||
if (defined('QDB_TESTING') && (
|
||||
$e instanceof \Tests\Support\JsonSuccessResponse
|
||||
|| $e instanceof \Tests\Support\JsonErrorResponse
|
||||
|| $e instanceof \Tests\Support\RawHttpResponse
|
||||
)) {
|
||||
throw $e;
|
||||
}
|
||||
require_once __DIR__ . '/../lib/errors.php';
|
||||
qdb_emit_api_error($e, "API $method $route");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user