31 lines
1.3 KiB
PHP
31 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api\V1\FullSurface;
|
|
|
|
use Tests\Feature\Api\V1\FullSurface\Support\FullSurfaceE2EContractCase;
|
|
|
|
class ApiRelationshipCardinalityContractTest extends FullSurfaceE2EContractCase
|
|
{
|
|
public function test_routes_expect_single_ids_do_not_crash_when_receiving_arrays_or_objects(): void
|
|
{
|
|
$routes = array_slice(array_filter($this->apiRoutes(), fn ($route) => in_array($this->primaryMethod($route), ['POST', 'PUT', 'PATCH'], true)), 0, 140);
|
|
|
|
foreach ($routes as $route) {
|
|
$method = $this->primaryMethod($route);
|
|
$uri = $route->uri();
|
|
$payload = $this->payloadFor($method, $uri) + [
|
|
'student_id' => [$this->ids['studentId'], 999999],
|
|
'parent_id' => ['id' => $this->ids['parentId']],
|
|
'teacher_id' => [$this->teacher->id],
|
|
'class_section_id' => ['unexpected' => $this->ids['classSectionId']],
|
|
'invoice_id' => [$this->ids['invoiceId']],
|
|
];
|
|
|
|
$response = $this->requestAs($this->actorFor($uri), $method, $uri, $payload);
|
|
|
|
$this->assertControlled($response, $method, $uri);
|
|
$this->assertNoServerError($response, 'relationship cardinality probe at '.$method.' '.$uri);
|
|
}
|
|
}
|
|
}
|