mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Major refactor
- update the structure to have monolithic setup - updated deployments - added live-reloading for devops
This commit is contained in:
49
tests/Integration/SearchTest.php
Normal file
49
tests/Integration/SearchTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Search Functionality Test
|
||||
* Tests search queries and results
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../lib/Database.php';
|
||||
|
||||
echo "Search Functionality Test\n";
|
||||
echo "=========================\n\n";
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
|
||||
// Test 1: Search with empty query
|
||||
echo "Test 1: Empty Search Query\n";
|
||||
$results = $db->searchTheses('');
|
||||
if (is_array($results)) {
|
||||
echo "✓ PASS: Empty query handled (returned " . count($results) . " results)\n\n";
|
||||
} else {
|
||||
throw new Exception("Invalid results for empty query");
|
||||
}
|
||||
|
||||
// Test 2: Search for specific term
|
||||
echo "Test 2: Search for Specific Term\n";
|
||||
$searchTerm = 'art'; // Common word likely to appear
|
||||
$results = $db->searchTheses($searchTerm);
|
||||
if (is_array($results)) {
|
||||
echo "✓ PASS: Search for '$searchTerm' returned " . count($results) . " results\n\n";
|
||||
} else {
|
||||
throw new Exception("Invalid search results");
|
||||
}
|
||||
|
||||
// Test 3: Search with special characters
|
||||
echo "Test 3: Search with Special Characters\n";
|
||||
$results = $db->searchTheses("test's \"quotes\" & symbols");
|
||||
if (is_array($results)) {
|
||||
echo "✓ PASS: Special characters handled safely\n\n";
|
||||
} else {
|
||||
throw new Exception("Failed to handle special characters");
|
||||
}
|
||||
|
||||
echo "✅ All search tests passed!\n";
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "❌ FAIL: " . $e->getMessage() . "\n";
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user