<?php
// test_db.php
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/functions.php';

echo "Testing database functions...<br><br>";

try {
    // Test getFeaturedProducts
    $featured = getFeaturedProducts($pdo, 4);
    echo "getFeaturedProducts() returned " . count($featured) . " products<br>";
    
    // Test getNewProducts
    $new = getNewProducts($pdo, 4);
    echo "getNewProducts() returned " . count($new) . " products<br>";
    
    // Test getTopSellingProducts
    $top = getTopSellingProducts($pdo, 4);
    echo "getTopSellingProducts() returned " . count($top) . " products<br>";
    
    // Test getCategories
    $categories = getCategories($pdo);
    echo "getCategories() returned " . count($categories) . " categories<br>";
    
    echo "<br>All tests passed successfully!";
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>