GET /billing/claims loaded every tenant claim with no limit. Add
findByTenant(page, limit) + countByTenant (shared query builder), default
limit 50 / max 100, and expose totals as data.meta — kept inside the existing
{ data: { data: [...] } } envelope so current clients are unaffected.
GET /wallet/transactions was already bounded (findByUser defaulted to limit 50)
but page-less; add page/offset + countByUser + the same additive meta.
Regression: tests/Billing/ClaimsListPaginationTest,
tests/Settlement/WalletTransactionsPaginationTest.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Billing;
|
|
|
|
use App\Billing\Entity\Claim;
|
|
use App\Doctor\Entity\Doctor;
|
|
use App\Tests\ApiTestCase;
|
|
|
|
/**
|
|
* GET /billing/claims must page rather than load every tenant claim, and expose
|
|
* totals in meta without breaking the existing data.data envelope.
|
|
*/
|
|
class ClaimsListPaginationTest extends ApiTestCase
|
|
{
|
|
public function testPaginatesAndReportsTotals(): void
|
|
{
|
|
$owner = $this->createUser(['ROLE_DOCTOR']);
|
|
$doctor = new Doctor($owner, 'دکتر تست');
|
|
$this->em->persist($doctor);
|
|
$this->em->flush();
|
|
|
|
for ($i = 0; $i < 7; $i++) {
|
|
$this->em->persist(new Claim('doctor', $doctor->getId(), 1, 'base'));
|
|
}
|
|
$this->em->flush();
|
|
|
|
$body = $this->authJson('GET', '/api/v1/billing/claims?limit=5', $owner);
|
|
$this->assertSame(200, $this->responseCode());
|
|
$this->assertCount(5, $body['data']['data']);
|
|
$this->assertSame(7, $body['data']['meta']['totalRecords']);
|
|
$this->assertSame(2, $body['data']['meta']['totalPages']);
|
|
|
|
$page2 = $this->authJson('GET', '/api/v1/billing/claims?limit=5&page=2', $owner);
|
|
$this->assertCount(2, $page2['data']['data']);
|
|
}
|
|
}
|