Files
alrahma_sunday_school_api/tests/Feature/Api/V1/FullSurface/ApiBatch20CashDrawerManualPaymentIntegrityContractTest.php
T
2026-06-09 02:32:58 -04:00

45 lines
2.1 KiB
PHP

<?php
namespace Tests\Feature\Api\V1\FullSurface;
use Tests\Feature\Api\V1\FullSurface\Support\FullSurfaceE2EContractCase;
class ApiBatch20CashDrawerManualPaymentIntegrityContractTest extends FullSurfaceE2EContractCase
{
public function test_batch20_cash_drawer_manual_payment_integrity_stays_controlled(): void
{
$routes = $this->apiRoutesContainingAny(['cash', 'drawer', 'payments', 'payment', 'finance', 'invoice', 'receipt', 'transactions', 'fees']);
$payload = [
'cash_drawer_id' => 999999,
'opened_by' => 999999,
'closed_by' => 999999,
'override_balance' => true,
'expected_total' => '0.00',
'actual_total' => '999999.99',
'manual_receipt_number' => 'CLIENT-FORGED-RECEIPT',
'payment_method' => 'cash',
'amount' => '-250.00',
];
foreach (array_slice($routes, 0, 120) as $route) {
$method = $this->primaryMethod($route);
$uri = $route->uri();
$actor = $this->actorFor($uri);
if (str_contains($uri, 'admin') || str_contains($uri, 'audit') || str_contains($uri, 'logs') || str_contains($uri, 'settings') || str_contains($uri, 'metrics') || str_contains($uri, 'health')) {
$actor = $this->studentUser;
}
$response = $this->requestAs($actor, $method, $uri, $this->payloadFor($method, $uri) + $payload);
$this->assertControlled($response, $method, $uri);
$this->assertNotEquals(500, $response->getStatusCode(), $method.' '.$uri.' crashed during Batch 20 cash drawer and manual payment integrity probe.');
$body = strtolower($response->getContent());
foreach (['sqlstate', 'stack trace', 'app_key', 'db_password', 'remember_token', 'api_token', 'password_hash', 'massassignmentexception', 'foreign key constraint', 'database.sqlite', '169.254.169.254'] as $leak) {
$this->assertStringNotContainsString($leak, $body, $method.' '.$uri.' leaked '.$leak.' during Batch 20 cash drawer and manual payment integrity probe.');
}
}
}
}