Guard invoice period flags by list permission
This commit is contained in:
@@ -45,12 +45,26 @@ it('streams the main period response instead of encoding the full payload at onc
|
||||
$content = (string)$content;
|
||||
|
||||
expect($content)->toContain('private static function streamInvoicingPeriodResponse(array $period): void')
|
||||
->and($content)->toContain('$period = self::getInvoicingPeriod($dateFrom, $dateTo, $customerNumbers);')
|
||||
->and($content)->toContain("$includeInvoicePeriodFlags = $this->hasPermission('list_invoice_period_flags');")
|
||||
->and($content)->toContain('$period = self::getInvoicingPeriod($dateFrom, $dateTo, $customerNumbers, $includeInvoicePeriodFlags);')
|
||||
->and($content)->toContain('self::streamInvoicingPeriodResponse($period);')
|
||||
->and($content)->not->toContain('$response->success([' . PHP_EOL . ' ...self::getInvoicingPeriod($dateFrom, $dateTo, $customerNumbers)')
|
||||
->and($content)->toContain('echo self::jsonFragment($customer);');
|
||||
});
|
||||
|
||||
it('only includes invoice period flags when the list permission is granted', function (): void {
|
||||
$content = file_get_contents(app_path('routes/InvoicingPeriodRoute.php'));
|
||||
|
||||
expect($content)->not->toBeFalse();
|
||||
$content = (string)$content;
|
||||
|
||||
expect($content)
|
||||
->toContain("$includeInvoicePeriodFlags = $this->hasPermission('list_invoice_period_flags');")
|
||||
->and($content)->toContain('bool $includeInvoicePeriodFlags = false')
|
||||
->and($content)->toContain('if ($includeInvoicePeriodFlags) {')
|
||||
->and($content)->toContain('applyFlagsToPeriodTypes(');
|
||||
});
|
||||
|
||||
it('maps batched period transaction rows to the legacy transaction response shape', function (): void {
|
||||
$reflection = new ReflectionClass(InvoicingPeriodRoute::class);
|
||||
$method = $reflection->getMethod('constructTransactionObjectFromPeriodRow');
|
||||
|
||||
Reference in New Issue
Block a user