fix gitlab tests

This commit is contained in:
root
2026-06-09 02:32:58 -04:00
parent 20a0b6c4e5
commit 6def9993da
1489 changed files with 10449 additions and 11356 deletions
@@ -22,9 +22,9 @@ use Tests\TestCase;
*/
class ApiFullSurfaceEndToEndContractTest extends TestCase
{
use AssertsE2EApiResponses;
use RefreshDatabase;
use SeedsE2ETestFixtures;
use AssertsE2EApiResponses;
/**
* @var array<string, int|string>
@@ -32,11 +32,8 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
private array $ids = [];
private User $admin;
private User $teacher;
private User $parent;
private User $studentUser;
protected function setUp(): void
@@ -98,7 +95,7 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
foreach ($this->probeableApiRoutes() as $route) {
$method = $this->primaryMethod($route);
$uri = '/'.$this->materializeUri($route->uri());
$uri = '/' . $this->materializeUri($route->uri());
$actor = $this->actorFor($route->uri());
$payload = $this->payloadFor($method, $route->uri());
@@ -107,17 +104,16 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
$status = $response->getStatusCode();
if ($status >= 500) {
$failures[] = "$method $uri crashed with $status: ".$response->getContent();
$failures[] = "$method $uri crashed with $status: " . $response->getContent();
continue;
}
if (! in_array($status, $this->allowedContractStatuses($method), true)) {
$failures[] = "$method $uri returned unexpected $status: ".$response->getContent();
$failures[] = "$method $uri returned unexpected $status: " . $response->getContent();
}
}
$this->assertSame([], $failures, "Full-surface API contract failures:\n".implode("\n", $failures));
$this->assertSame([], $failures, "Full-surface API contract failures:\n" . implode("\n", $failures));
}
public function test_all_mutating_api_routes_reject_empty_or_malformed_payloads_without_server_errors(): void
@@ -130,17 +126,17 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
continue;
}
$uri = '/'.$this->materializeUri($route->uri());
$uri = '/' . $this->materializeUri($route->uri());
$this->actingAs($this->actorFor($route->uri()), 'api');
$response = $this->json($method, $uri, []);
$status = $response->getStatusCode();
if ($status >= 500) {
$failures[] = "$method $uri malformed payload crashed with $status: ".$response->getContent();
$failures[] = "$method $uri malformed payload crashed with $status: " . $response->getContent();
}
}
$this->assertSame([], $failures, "Malformed-payload probes must fail cleanly, not explode:\n".implode("\n", $failures));
$this->assertSame([], $failures, "Malformed-payload probes must fail cleanly, not explode:\n" . implode("\n", $failures));
}
public function test_portal_routes_enforce_wrong_actor_boundaries_across_the_full_surface(): void
@@ -153,11 +149,11 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
$status = $response->getStatusCode();
if (! in_array($status, [401, 403, 404, 405, 419, 422], true)) {
$failures[] = "$method $uri allowed wrong actor with $status: ".$response->getContent();
$failures[] = "$method $uri allowed wrong actor with $status: " . $response->getContent();
}
}
$this->assertSame([], $failures, "Wrong-role portal boundary failures:\n".implode("\n", $failures));
$this->assertSame([], $failures, "Wrong-role portal boundary failures:\n" . implode("\n", $failures));
}
/**
@@ -233,14 +229,13 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
{
return preg_replace_callback('/\{([^}:]+)(?:\?)?[^}]*\}/', function (array $matches): string {
$key = $matches[1];
return (string) ($this->ids[$key] ?? $this->ids['id']);
}, $uri) ?? $uri;
}
private function materializePath(string $path): string
{
return '/'.ltrim($this->materializeUri(ltrim($path, '/')), '/');
return '/' . ltrim($this->materializeUri(ltrim($path, '/')), '/');
}
/**
@@ -272,7 +267,15 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
'firstname' => 'Contract',
'lastname' => 'Student',
'dob' => '2015-01-01',
'age' => 10,
'gender' => 'Male',
'photo_consent' => true,
'is_new' => true,
'is_active' => true,
'registration_grade' => '5',
'registration_date' => '2025-09-01',
'tuition_paid' => false,
'year_of_registration' => 2025,
'parent_id' => $this->ids['parentId'],
'student_id' => $this->ids['studentId'],
'class_section_id' => [$this->ids['classSectionId']],
@@ -314,7 +317,7 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
if (str_contains($uri, 'inventory') || str_contains($uri, 'suppliers') || str_contains($uri, 'supply')) {
return $base + [
'name' => 'Contract Probe Item',
'sku' => 'E2E-'.uniqid(),
'sku' => 'E2E-' . uniqid(),
'quantity' => 3,
'unit_cost' => 5.25,
];