<?php
/**
 * Enhanced smoke test for HVAC Community Events plugin
 */

// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Load test environment
require_once dirname(__DIR__) . '/bootstrap-staging.php';

function log_test_step($step, $message) {
    error_log("[HVAC SMOKE TEST] Step $step: $message");
    echo "[HVAC SMOKE TEST] Step $step: $message\n";
}

// Step 1: Verify WordPress loaded
log_test_step(1, "Verifying WordPress environment...");
if (!defined('ABSPATH')) {
    log_test_step(1, "FAIL: WordPress environment not loaded");
    exit(1);
}
log_test_step(1, "PASS: WordPress environment verified");

// Step 2: Verify test doubles loaded
log_test_step(2, "Checking test doubles...");
if (!class_exists('Tribe__Events__Main')) {
    log_test_step(2, "FAIL: TEC test doubles not loaded");
    exit(1);
}
log_test_step(2, "PASS: Test doubles verified");

// Step 3: Verify plugin loaded
log_test_step(3, "Checking plugin class...");
if (!class_exists('HVAC_Community_Events')) {
    log_test_step(3, "FAIL: Plugin class not loaded");
    exit(1);
}
log_test_step(3, "PASS: Plugin class verified");

// Step 4: Verify version constant
log_test_step(4, "Checking version constant...");
if (!defined('HVAC_CE_VERSION')) {
    log_test_step(4, "FAIL: Version constant not defined");
    exit(1);
}
log_test_step(4, "PASS: Version constant verified");

// Step 5: Verify TEC functions
log_test_step(5, "Checking TEC functions...");
$required_functions = [
    'tribe_get_events',
    'tribe_get_start_date',
    'tribe_get_end_date'
];

foreach ($required_functions as $function) {
    if (!function_exists($function)) {
        log_test_step(5, "FAIL: Required TEC function '$function' not available");
        exit(1);
    }
}
log_test_step(5, "PASS: All required TEC functions verified");

log_test_step('FINAL', "All smoke test checks completed successfully");
exit(0);