Skip to content

Commit df458ba

Browse files
committed
test(money): cover converter known currency narrowing
1 parent 2d44d3a commit df458ba

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

money/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "phpstan-extension",
66
"require": {
77
"php": "^8.4",
8-
"brick/money": "^0.13 || ^0.14 || ^0.15 || ^0.16 || ^0.17 || ^0.18",
8+
"brick/money": "^0.13",
99
"phpstan/phpstan": "^2.1"
1010
},
1111
"require-dev": {

money/tests/data/MoneyThrowTypes.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Brick\Math\BigDecimal;
88
use Brick\Math\BigInteger;
9+
use Brick\Math\Exception\RoundingNecessaryException;
910
use Brick\Math\RoundingMode;
1011
use Brick\Money\Context\CustomContext;
1112
use Brick\Money\Currency;
@@ -342,6 +343,19 @@ public function convertWithSafeCurrency(CurrencyConverter $converter, Money $mon
342343
}
343344
}
344345

346+
public function convertWithSafeCurrencyCatchingResidualExceptions(
347+
CurrencyConverter $converter,
348+
Money $money,
349+
): void {
350+
try {
351+
$result = $converter->convert($money, 'USD');
352+
} catch (ExchangeRateException | RoundingNecessaryException) {
353+
$result = $money;
354+
} finally {
355+
assertVariableCertainty(TrinaryLogic::createYes(), $result);
356+
}
357+
}
358+
345359
public function convertWithSafeCurrencyAndRoundingMode(CurrencyConverter $converter, Money $money): void
346360
{
347361
try {

0 commit comments

Comments
 (0)