count(3)->create(); }); it('returns 200 OK for default inco-sheets list request', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson('/api/v1/inco-sheets'); // THEN $response->assertStatus(200); $response->assertJsonStructure([ 'incoSheets', 'pagination' => [ 'page', 'pageSize', 'totalItems', 'totalPages', 'links', ], ]); }); it('returns 200 OK for page and pageSize pagination query', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson('/api/v1/inco-sheets?page=1&pageSize=2'); // THEN $response->assertStatus(200); $response->assertJsonPath('pagination.pageSize', 2); }); it('returns 200 OK for offset and limit pagination query', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson('/api/v1/inco-sheets?offset=0&limit=2'); // THEN $response->assertStatus(200); $response->assertJsonPath('pagination.pageSize', 2); }); it('returns 200 OK for sorting query parameters', function (string $sortBy, string $direction): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson("/api/v1/inco-sheets?sortBy={$sortBy}&sortDirection={$direction}"); // THEN $response->assertStatus(200); })->with([ ['incoSheetId', 'Ascending'], ['createdAt', 'Descending'], ['updatedAt', 'Ascending'], ]); it('returns 200 OK with short form inco sheets when short parameter is true', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson('/api/v1/inco-sheets?short=true'); // THEN $response->assertStatus(200); $response->assertJsonStructure([ 'incoSheets' => [ '*' => [ 'id', 'name', 'label', 'createdAt', 'updatedAt', ], ], 'pagination', ]); $firstItem = $response->json('incoSheets.0'); expect($firstItem) ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) ->and($firstItem)->not->toHaveKey('description') ->and($firstItem)->not->toHaveKey('allegations') ->and($firstItem)->not->toHaveKey('ingredients') ->and($firstItem)->not->toHaveKey('brand'); }); it('returns 200 OK with short form inco sheets when short parameter is numeric 1', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; // WHEN $response = $test->getJson('/api/v1/inco-sheets?short=1'); // THEN $response->assertStatus(200); $response->assertJsonStructure([ 'incoSheets' => [ '*' => [ 'id', 'name', 'label', 'createdAt', 'updatedAt', ], ], 'pagination', ]); $firstItem = $response->json('incoSheets.0'); expect($firstItem) ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) ->and($firstItem)->not->toHaveKey('description') ->and($firstItem)->not->toHaveKey('ingredients'); }); });