diff --git a/composer.json b/composer.json index 5588b085..2d2679be 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "php-http/message": "^1.16.0", "php-http/mock-client": "^1.6.0", "phpbench/phpbench": "^1.2.5", - "phpunit/phpunit": "^9.5.4", + "phpunit/phpunit": "^10.5.9", "psalm/plugin-phpunit": "^0.18.4", "psr/cache": "^1.0.1 || ^2.0 || ^3.0", "vimeo/psalm": "~5.20.0" @@ -88,13 +88,13 @@ ], "clean": "rm -rf build/ vendor/", "test": [ - "vendor/bin/phpunit -v", "vendor/bin/phpbench run", + "vendor/bin/phpunit", "vendor/bin/psalm", "vendor/bin/phpcs" ], "test-coverage": [ - "vendor/bin/phpunit -v --coverage-text --coverage-clover=build/unit_coverage.xml" + "vendor/bin/phpunit --coverage-text --coverage-clover=build/unit_coverage.xml" ], "update-currencies": [ "cp vendor/moneyphp/iso-currencies/resources/current.php resources/currency.php", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b4d5ed76..9f3d4218 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,21 +4,19 @@ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true" - verbose="true" columns="max" - beStrictAboutTestsThatDoNotTestAnything="true" - beStrictAboutResourceUsageDuringSmallTests="true" beStrictAboutChangesToGlobalState="true" > - - - tests/ - - - - - src - - + + + tests/ + + + + + + src + + diff --git a/src/PHPUnit/Comparator.php b/src/PHPUnit/Comparator.php index 28a5d4ea..8f211478 100644 --- a/src/PHPUnit/Comparator.php +++ b/src/PHPUnit/Comparator.php @@ -31,8 +31,6 @@ final class Comparator extends \SebastianBergmann\Comparator\Comparator public function __construct() { - parent::__construct(); - $currencies = new AggregateCurrencies([ new ISOCurrencies(), new BitcoinCurrencies(), @@ -43,15 +41,21 @@ public function __construct() } /** {@inheritDoc} */ - public function accepts($expected, $actual) + public function accepts(mixed $expected, mixed $actual): bool { return $expected instanceof Money && $actual instanceof Money; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @param float $delta + * @param bool $canonicalize + * @param bool $ignoreCase + */ public function assertEquals( - $expected, - $actual, + mixed $expected, + mixed $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false @@ -60,7 +64,7 @@ public function assertEquals( assert($actual instanceof Money); if (! $expected->equals($actual)) { - throw new ComparisonFailure($expected, $actual, $this->formatter->format($expected), $this->formatter->format($actual), false, 'Failed asserting that two Money objects are equal.'); + throw new ComparisonFailure($expected, $actual, $this->formatter->format($expected), $this->formatter->format($actual), 'Failed asserting that two Money objects are equal.'); } } } diff --git a/tests/AggregateExamples.php b/tests/AggregateExamples.php index 59befdfd..d6cc67f6 100644 --- a/tests/AggregateExamples.php +++ b/tests/AggregateExamples.php @@ -9,7 +9,7 @@ trait AggregateExamples { /** @psalm-return non-empty-list, Money}> */ - public function sumExamples(): array + public static function sumExamples(): array { return [ [[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(30)], @@ -19,7 +19,7 @@ public function sumExamples(): array } /** @psalm-return non-empty-list, Money}> */ - public function minExamples(): array + public static function minExamples(): array { return [ [[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(5)], @@ -29,7 +29,7 @@ public function minExamples(): array } /** @psalm-return non-empty-list, Money}> */ - public function maxExamples(): array + public static function maxExamples(): array { return [ [[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(15)], @@ -39,7 +39,7 @@ public function maxExamples(): array } /** @psalm-return non-empty-list, Money}> */ - public function avgExamples(): array + public static function avgExamples(): array { return [ [[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(10)], diff --git a/tests/Calculator/BcMathCalculatorTest.php b/tests/Calculator/BcMathCalculatorTest.php index 9d4d0391..f219d483 100644 --- a/tests/Calculator/BcMathCalculatorTest.php +++ b/tests/Calculator/BcMathCalculatorTest.php @@ -116,7 +116,7 @@ public function itRefusesToModuloByZeroWhenDivisorIsTooSmallToCompare(): void /** * @psalm-return array> */ - public function compareLessExamples(): array + public static function compareLessExamples(): array { return array_merge( parent::compareLessExamples(), diff --git a/tests/Calculator/CalculatorTestCase.php b/tests/Calculator/CalculatorTestCase.php index ac80e61d..80ca1c54 100644 --- a/tests/Calculator/CalculatorTestCase.php +++ b/tests/Calculator/CalculatorTestCase.php @@ -250,7 +250,7 @@ public function itRefusesToModuloByNegativeZero(): void * numeric-string * }> */ - public function additionExamples(): array + public static function additionExamples(): array { return [ [1, 1, '2'], @@ -265,7 +265,7 @@ public function additionExamples(): array * numeric-string * }> */ - public function subtractionExamples(): array + public static function subtractionExamples(): array { return [ [1, 1, '0'], @@ -280,7 +280,7 @@ public function subtractionExamples(): array * numeric-string * }> */ - public function multiplicationExamples(): array + public static function multiplicationExamples(): array { return [ [1, 1.5, '1.5'], @@ -306,7 +306,7 @@ public function multiplicationExamples(): array * numeric-string * }> */ - public function divisionExamples(): array + public static function divisionExamples(): array { return [ [6, 3, '2'], @@ -333,7 +333,7 @@ public function divisionExamples(): array * numeric-string * }> */ - public function divisionExactExamples(): array + public static function divisionExactExamples(): array { return [ [6, 3, '2'], @@ -352,7 +352,7 @@ public function divisionExactExamples(): array * numeric-string * }> */ - public function ceilExamples(): array + public static function ceilExamples(): array { return [ [1.2, '2'], @@ -367,7 +367,7 @@ public function ceilExamples(): array * numeric-string * }> */ - public function floorExamples(): array + public static function floorExamples(): array { return [ [2.7, '2'], @@ -382,7 +382,7 @@ public function floorExamples(): array * numeric-string * }> */ - public function absoluteExamples(): array + public static function absoluteExamples(): array { return [ [2, '2'], @@ -398,7 +398,7 @@ public function absoluteExamples(): array * numeric-string * }> */ - public function shareExamples(): array + public static function shareExamples(): array { return [ [10, 2, 4, '5'], @@ -408,7 +408,7 @@ public function shareExamples(): array /** * @psalm-return array> */ - public function compareLessExamples(): array + public static function compareLessExamples(): array { return [ [0, 1], @@ -427,7 +427,7 @@ public function compareLessExamples(): array * int|numeric-string * }> */ - public function compareEqualExamples(): array + public static function compareEqualExamples(): array { return [ [1, 1], @@ -443,7 +443,7 @@ public function compareEqualExamples(): array * numeric-string * }> */ - public function modExamples(): array + public static function modExamples(): array { return [ [11, 5, '1'], diff --git a/tests/Calculator/GmpCalculatorTest.php b/tests/Calculator/GmpCalculatorTest.php index a2388d76..60e2d8c8 100644 --- a/tests/Calculator/GmpCalculatorTest.php +++ b/tests/Calculator/GmpCalculatorTest.php @@ -58,7 +58,7 @@ public function it_divides_bug538(): void /** * @psalm-return array> */ - public function compareLessExamples(): array + public static function compareLessExamples(): array { return array_merge( parent::compareLessExamples(), diff --git a/tests/ConverterTest.php b/tests/ConverterTest.php index c853d0e7..6dad6ca5 100644 --- a/tests/ConverterTest.php +++ b/tests/ConverterTest.php @@ -231,7 +231,7 @@ public function itThrowsWhenConvertingAgainstTheWrongBaseCurrency(): void * positive-int|0 * }> */ - public function convertExamples(): array + public static function convertExamples(): array { return [ ['USD', 'JPY', 2, 0, 101, 100, 101], diff --git a/tests/Currencies/CryptoCurrenciesTest.php b/tests/Currencies/CryptoCurrenciesTest.php index dabf8e7e..4843d017 100644 --- a/tests/Currencies/CryptoCurrenciesTest.php +++ b/tests/Currencies/CryptoCurrenciesTest.php @@ -68,7 +68,7 @@ public function itIsIterable(): void /** * @psalm-return non-empty-list */ - public function currencyCodeExamples(): array + public static function currencyCodeExamples(): array { /** @psalm-var non-empty-array $currencies */ $currencies = require __DIR__ . '/../../resources/binance.php'; diff --git a/tests/Currencies/CurrencyListTest.php b/tests/Currencies/CurrencyListTest.php index 1d6e073a..911c77c9 100644 --- a/tests/Currencies/CurrencyListTest.php +++ b/tests/Currencies/CurrencyListTest.php @@ -72,7 +72,7 @@ public function itIsIterable(): void } /** @psalm-return non-empty-list */ - public function currencyCodeExamples(): array + public static function currencyCodeExamples(): array { $currencies = array_keys(self::CORRECT_CURRENCIES); diff --git a/tests/Currencies/ISOCurrenciesTest.php b/tests/Currencies/ISOCurrenciesTest.php index 856862b2..726e58f3 100644 --- a/tests/Currencies/ISOCurrenciesTest.php +++ b/tests/Currencies/ISOCurrenciesTest.php @@ -93,7 +93,7 @@ public function itIsIterable(): void /** * @psalm-return non-empty-list */ - public function currencyCodeExamples(): array + public static function currencyCodeExamples(): array { /** @psalm-var non-empty-array $currencies */ $currencies = require __DIR__ . '/../../resources/currency.php'; diff --git a/tests/Exchange/SwapExchangeTest.php b/tests/Exchange/SwapExchangeTest.php index a9978fab..bc31e694 100644 --- a/tests/Exchange/SwapExchangeTest.php +++ b/tests/Exchange/SwapExchangeTest.php @@ -22,7 +22,7 @@ final class SwapExchangeTest extends TestCase * numeric-string * }> */ - public function exchangeRateExamples(): array + public static function exchangeRateExamples(): array { return [ [1.25, '1.25000000000000'], diff --git a/tests/Formatter/BitcoinMoneyFormatterTest.php b/tests/Formatter/BitcoinMoneyFormatterTest.php index 85be82c0..eda46162 100644 --- a/tests/Formatter/BitcoinMoneyFormatterTest.php +++ b/tests/Formatter/BitcoinMoneyFormatterTest.php @@ -44,7 +44,7 @@ public function itFormatsMoney(int $value, string $formatted, int $fractionDigit * positive-int|0 * }> */ - public function bitcoinExamples(): array + public static function bitcoinExamples(): array { return [ [100000000000, "\xC9\x831000.00", 2], diff --git a/tests/MoneyFactoryTest.php b/tests/MoneyFactoryTest.php index 0d952435..80c5e6e6 100644 --- a/tests/MoneyFactoryTest.php +++ b/tests/MoneyFactoryTest.php @@ -28,7 +28,7 @@ public function itCreatesMoneyUsingFactories(Currency $currency): void } /** @psalm-return list */ - public function currencyExamples(): array + public static function currencyExamples(): array { $currencies = new AggregateCurrencies([ new ISOCurrencies(), diff --git a/tests/MoneyTest.php b/tests/MoneyTest.php index 1827ba8d..a6aeff39 100644 --- a/tests/MoneyTest.php +++ b/tests/MoneyTest.php @@ -458,7 +458,7 @@ public function itThrowsWhenComparingDifferentCurrencies(): void * bool * }> */ - public function equalityExamples(): array + public static function equalityExamples(): array { return [ [10, new Currency(self::CURRENCY), true], @@ -475,7 +475,7 @@ public function equalityExamples(): array * int * }> */ - public function comparisonExamples(): array + public static function comparisonExamples(): array { return [ [self::AMOUNT, 0], @@ -491,7 +491,7 @@ public function comparisonExamples(): array * non-empty-array * }> */ - public function allocationExamples(): array + public static function allocationExamples(): array { return [ [100, [1, 1, 1], [34, 33, 33]], @@ -521,7 +521,7 @@ public function allocationExamples(): array * non-empty-list * }> */ - public function allocationTargetExamples(): array + public static function allocationTargetExamples(): array { return [ [15, 2, [8, 7]], @@ -539,7 +539,7 @@ public function allocationTargetExamples(): array * bool * }> */ - public function comparatorExamples(): array + public static function comparatorExamples(): array { return [ [1, false, true, false], @@ -557,7 +557,7 @@ public function comparatorExamples(): array * positive-int|0 * }> */ - public function absoluteExamples(): array + public static function absoluteExamples(): array { return [ [1, 1], @@ -575,7 +575,7 @@ public function absoluteExamples(): array * int * }> */ - public function negativeExamples(): array + public static function negativeExamples(): array { return [ [1, -1], @@ -594,7 +594,7 @@ public function negativeExamples(): array * numeric-string * }> */ - public function modExamples(): array + public static function modExamples(): array { return [ [11, 5, '1'], @@ -612,7 +612,7 @@ public function modExamples(): array * int * }> */ - public function roundToUnitExamples(): array + public static function roundToUnitExamples(): array { return [ [510, 2, 500, Money::ROUND_HALF_UP], diff --git a/tests/NumberTest.php b/tests/NumberTest.php index 08e5aa47..fe5e797e 100644 --- a/tests/NumberTest.php +++ b/tests/NumberTest.php @@ -104,7 +104,7 @@ public function itCreatesANumberFromAFloatingPointValue(): void * the {@see PHP_INT_MAX} operations below cannot be inferred to numeric-string * concatenation of {@see PHP_INT_MAX} is disallowed by type checker, but valid in this scenario */ - public function numberExamples(): array + public static function numberExamples(): array { return [ ['0', false, false, true, false, '0', ''], @@ -162,7 +162,7 @@ public function numberExamples(): array } /** @psalm-return non-empty-list */ - public function invalidNumberExamples() + public static function invalidNumberExamples(): array { return [ [''], @@ -187,7 +187,7 @@ public function invalidNumberExamples() * numeric-string * }> */ - public function base10Examples() + public static function base10Examples(): array { return [ ['0', 10, '0'], @@ -208,7 +208,7 @@ public function base10Examples() } /** @psalm-return non-empty-list */ - public function numericExamples(): array + public static function numericExamples(): array { return [ [1], diff --git a/tests/Parser/BitcoinMoneyParserTest.php b/tests/Parser/BitcoinMoneyParserTest.php index 4a7eb1f0..47954852 100644 --- a/tests/Parser/BitcoinMoneyParserTest.php +++ b/tests/Parser/BitcoinMoneyParserTest.php @@ -51,7 +51,7 @@ public function forceCurrencyWorks(): void * int|numeric-string * }> */ - public function bitcoinExamples(): array + public static function bitcoinExamples(): array { return [ ["\xC9\x831000.00", 100000], diff --git a/tests/Parser/DecimalMoneyParserTest.php b/tests/Parser/DecimalMoneyParserTest.php index 28fdd9f0..184146f2 100644 --- a/tests/Parser/DecimalMoneyParserTest.php +++ b/tests/Parser/DecimalMoneyParserTest.php @@ -62,7 +62,7 @@ public function itThrowsAnExceptionUponInvalidInputs($input): void * int * }> */ - public function formattedMoneyExamples(): array + public static function formattedMoneyExamples(): array { return [ ['1000.50', 'USD', 2, 100050], diff --git a/tests/Parser/IntlLocalizedDecimalParserTest.php b/tests/Parser/IntlLocalizedDecimalParserTest.php index 7bf4d9c0..168ffd32 100644 --- a/tests/Parser/IntlLocalizedDecimalParserTest.php +++ b/tests/Parser/IntlLocalizedDecimalParserTest.php @@ -118,7 +118,7 @@ public function it_does_not_support_invalid_decimal(): void * non-empty-string * }> */ - public function formattedMoneyExamples() + public static function formattedMoneyExamples(): array { return [ ['1000.50', 100050, 'en_US'], diff --git a/tests/Parser/IntlMoneyParserTest.php b/tests/Parser/IntlMoneyParserTest.php index a1b726f0..1f68901d 100644 --- a/tests/Parser/IntlMoneyParserTest.php +++ b/tests/Parser/IntlMoneyParserTest.php @@ -126,7 +126,7 @@ public function itSupportsFractionDigitsWithDifferentStyleAndPattern(): void * int * }> */ - public function formattedMoneyExamples(): array + public static function formattedMoneyExamples(): array { return [ ['$1000.50', 100050], diff --git a/tests/RoundExamples.php b/tests/RoundExamples.php index 46bebd2d..3d1adfda 100644 --- a/tests/RoundExamples.php +++ b/tests/RoundExamples.php @@ -20,7 +20,7 @@ trait RoundExamples * 2: numeric-string * }> */ - public function roundingExamples(): array + public static function roundingExamples(): array { return [ ['2.6', Money::ROUND_HALF_EVEN, '3'],