Fix Laravel Pint formatting
This commit is contained in:
@@ -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,8 +32,11 @@ class ApiFullSurfaceEndToEndContractTest extends TestCase
|
||||
private array $ids = [];
|
||||
|
||||
private User $admin;
|
||||
|
||||
private User $teacher;
|
||||
|
||||
private User $parent;
|
||||
|
||||
private User $studentUser;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -95,7 +98,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());
|
||||
|
||||
@@ -104,16 +107,17 @@ 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
|
||||
@@ -126,17 +130,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
|
||||
@@ -149,11 +153,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,13 +233,14 @@ 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, '/')), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +314,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,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user