37487-vm/test_cases.php
2026-01-15 17:29:08 +00:00

97 lines
4.6 KiB
PHP

<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query('SELECT * FROM test_cases ORDER BY created_at DESC');
$test_cases = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Case Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<style>
body { background-color: #f8fafc; }
.card { border: 1px solid #e2e8f0; }
</style>
</head>
<body>
<div class="container py-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3">Test Case Dashboard</h1>
<a href="add_test_case.php" class="btn btn-primary d-inline-flex align-items-center">
<i data-feather="plus" class="me-2"></i>Add New Test Case
</a>
</div>
<div class="card">
<div class="card-body">
<?php if (empty($test_cases)): ?>
<div class="text-center py-5">
<p class="mb-0">No test cases found.</p>
</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th scope="col">Title</th>
<th scope="col">Status</th>
<th scope="col">Created At</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($test_cases as $test_case): ?>
<tr>
<td><?php echo htmlspecialchars($test_case['title']); ?></td>
<td>
<?php
$status_color = 'secondary';
switch ($test_case['status']) {
case 'Passed':
$status_color = 'success';
break;
case 'Failed':
$status_color = 'danger';
break;
case 'Blocked':
$status_color = 'warning';
break;
}
?>
<span class="badge bg-<?php echo $status_color; ?>"><?php echo htmlspecialchars($test_case['status']); ?></span>
</td>
<td><?php echo htmlspecialchars($test_case['created_at']); ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-secondary d-inline-flex align-items-center me-2">
<i data-feather="eye" class="me-1"></i>View
</a>
<?php if ($test_case['status'] === 'Failed'): ?>
<a href="add_bug.php?test_case_id=<?php echo $test_case['id']; ?>" class="btn btn-sm btn-danger d-inline-flex align-items-center me-2">
<i data-feather="plus" class="me-1"></i>Add Bug
</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<div class="text-center mt-4">
<a href="index.php">Back to Home</a>
</div>
</div>
<script>
feather.replace()
</script>
</body>
</html>