refactor: extract buildSearchConditions, add getThesesList, remove dead code, fix SearchTest

- Database: extract private buildSearchConditions(array $params): array shared by
  searchTheses() and countSearchResults(), eliminating ~80 lines of duplication;
  add array type hints to both public methods
- Database: add getThesesList(array $filters) and getAllYears() so admin/index.php
  no longer builds raw SQL inline
- admin/index.php: replace inline PDO query block with $db->getThesesList() /
  $db->getAllYears(); drop the now-unused $pdo local
- config/bootstrap.php: remove dead include_template() helper and the
  vendor/autoload.php Composer stub (no vendor/ directory exists)
- apps/: delete entire directory (leftover artefact, no code references it)
- tests/Integration/SearchTest.php: fix three searchTheses() calls from bare
  strings to proper array params to match the method signature (prevented TypeError)
This commit is contained in:
Pontoporeia
2026-02-24 23:21:44 +01:00
parent d30153871f
commit eaad740574
8 changed files with 102 additions and 375 deletions

View File

@@ -14,7 +14,7 @@ try {
// Test 1: Search with empty query
echo "Test 1: Empty Search Query\n";
$results = $db->searchTheses('');
$results = $db->searchTheses([]);
if (is_array($results)) {
echo "✓ PASS: Empty query handled (returned " . count($results) . " results)\n\n";
} else {
@@ -24,7 +24,7 @@ try {
// 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);
$results = $db->searchTheses(['query' => $searchTerm]);
if (is_array($results)) {
echo "✓ PASS: Search for '$searchTerm' returned " . count($results) . " results\n\n";
} else {
@@ -33,7 +33,7 @@ try {
// Test 3: Search with special characters
echo "Test 3: Search with Special Characters\n";
$results = $db->searchTheses("test's \"quotes\" & symbols");
$results = $db->searchTheses(['query' => "test's \"quotes\" & symbols"]);
if (is_array($results)) {
echo "✓ PASS: Special characters handled safely\n\n";
} else {