36 lines
1.5 KiB
PHP
36 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api\V1\FullSurface;
|
|
|
|
use Tests\Feature\Api\V1\FullSurface\Support\FullSurfaceE2EContractCase;
|
|
|
|
class ApiBatch16MoneyPrecisionCurrencyContractTest extends FullSurfaceE2EContractCase
|
|
{
|
|
public function test_batch16_money_routes_reject_precision_currency_and_rounding_abuse_cleanly(): void
|
|
{
|
|
$routes = $this->apiRoutesContainingAny(['finance', 'invoice', 'payment', 'refund', 'fee', 'charge', 'discount', 'voucher', 'scholarship']);
|
|
$payloads = [
|
|
['amount' => '0.001', 'currency' => 'USD'],
|
|
['amount' => '999999999999999999.99', 'currency' => 'USD'],
|
|
['amount' => '12,34', 'currency' => 'USD'],
|
|
['amount' => '25.00', 'currency' => 'BTC'],
|
|
['amount' => '-0.01', 'currency' => 'USD'],
|
|
['amount' => 'NaN', 'currency' => 'USD'],
|
|
];
|
|
|
|
foreach (array_slice($routes, 0, 45) as $route) {
|
|
$method = $this->primaryMethod($route);
|
|
$uri = $route->uri();
|
|
foreach ($payloads as $probe) {
|
|
$response = $this->requestAs($this->actorFor($uri), $method, $uri, $this->payloadFor($method, $uri) + $probe + [
|
|
'rounding_mode' => 'client_controls_rounding',
|
|
'override_total' => true,
|
|
'ledger_balance' => -100,
|
|
]);
|
|
$this->assertControlled($response, $method, $uri);
|
|
$this->assertStringNotContainsString('division by zero', strtolower($response->getContent()));
|
|
}
|
|
}
|
|
}
|
|
}
|