<?php
// Test file for favorites API
require_once 'includes/config.php';
require_once 'includes/db.php';
require_once 'includes/functions.php';

header('Content-Type: application/json');

// Simulate a logged in user
session_start();

if (!isset($_SESSION['user_id'])) {
    $_SESSION['user_id'] = 1; // Simulate user ID 1
}

// Test the getFavoriteProducts function
try {
    $favorites = getFavoriteProducts($pdo, $_SESSION['user_id']);
    echo json_encode([
        'success' => true,
        'favorites' => $favorites,
        'count' => count($favorites)
    ]);
} catch (Exception $e) {
    echo json_encode([
        'success' => false,
        'error' => $e->getMessage()
    ]);
}
?>