<?php
// tests/bootstrap.php — shared setup for the test suite.
// Provides minimal $_SERVER values, then loads the app's helpers.
// Pure helper functions are tested; DB/session-bound functions are not
// exercised here (they require a live database).

error_reporting(E_ALL & ~E_DEPRECATED);

$_SERVER['DOCUMENT_ROOT']  = $_SERVER['DOCUMENT_ROOT']  ?? dirname(__DIR__);
$_SERVER['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD'] ?? 'GET';
$_SERVER['REMOTE_ADDR']    = $_SERVER['REMOTE_ADDR']    ?? '127.0.0.1';
$_SERVER['HTTP_HOST']      = $_SERVER['HTTP_HOST']      ?? 'localhost';

// Define DB constants up front so config.php doesn't hard-exit if
// config.local.php is absent in the test environment.
if (!defined('DB_HOST')) define('DB_HOST', 'localhost');
if (!defined('DB_NAME')) define('DB_NAME', 'test');
if (!defined('DB_USER')) define('DB_USER', 'test');
if (!defined('DB_PASS')) define('DB_PASS', '');
if (!defined('BASE_URL')) define('BASE_URL', 'https://example.test');

require_once dirname(__DIR__) . '/config.php';
