Skip to content

Commit

Permalink
chore: upgrade PHPUnit 9 => 10
Browse files Browse the repository at this point in the history
changes for sebastian/comparator
  • Loading branch information
Firehed authored and Chris8934 committed Jan 27, 2024
1 parent a829bd4 commit 4c67318
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 66 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 11 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<testsuites>
<testsuite name="Money Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Money Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
18 changes: 11 additions & 7 deletions src/PHPUnit/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ final class Comparator extends \SebastianBergmann\Comparator\Comparator

public function __construct()
{
parent::__construct();

$currencies = new AggregateCurrencies([
new ISOCurrencies(),
new BitcoinCurrencies(),
Expand All @@ -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
Expand All @@ -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.');
}
}
}
8 changes: 4 additions & 4 deletions tests/AggregateExamples.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
trait AggregateExamples
{
/** @psalm-return non-empty-list<array{non-empty-list<Money>, Money}> */
public function sumExamples(): array
public static function sumExamples(): array
{
return [
[[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(30)],
Expand All @@ -19,7 +19,7 @@ public function sumExamples(): array
}

/** @psalm-return non-empty-list<array{non-empty-list<Money>, Money}> */
public function minExamples(): array
public static function minExamples(): array
{
return [
[[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(5)],
Expand All @@ -29,7 +29,7 @@ public function minExamples(): array
}

/** @psalm-return non-empty-list<array{non-empty-list<Money>, Money}> */
public function maxExamples(): array
public static function maxExamples(): array
{
return [
[[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(15)],
Expand All @@ -39,7 +39,7 @@ public function maxExamples(): array
}

/** @psalm-return non-empty-list<array{non-empty-list<Money>, Money}> */
public function avgExamples(): array
public static function avgExamples(): array
{
return [
[[Money::EUR(5), Money::EUR(10), Money::EUR(15)], Money::EUR(10)],
Expand Down
2 changes: 1 addition & 1 deletion tests/Calculator/BcMathCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function itRefusesToModuloByZeroWhenDivisorIsTooSmallToCompare(): void
/**
* @psalm-return array<int,array<int|numeric-string>>
*/
public function compareLessExamples(): array
public static function compareLessExamples(): array
{
return array_merge(
parent::compareLessExamples(),
Expand Down
24 changes: 12 additions & 12 deletions tests/Calculator/CalculatorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function itRefusesToModuloByNegativeZero(): void
* numeric-string
* }>
*/
public function additionExamples(): array
public static function additionExamples(): array
{
return [
[1, 1, '2'],
Expand All @@ -265,7 +265,7 @@ public function additionExamples(): array
* numeric-string
* }>
*/
public function subtractionExamples(): array
public static function subtractionExamples(): array
{
return [
[1, 1, '0'],
Expand All @@ -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'],
Expand All @@ -306,7 +306,7 @@ public function multiplicationExamples(): array
* numeric-string
* }>
*/
public function divisionExamples(): array
public static function divisionExamples(): array
{
return [
[6, 3, '2'],
Expand All @@ -333,7 +333,7 @@ public function divisionExamples(): array
* numeric-string
* }>
*/
public function divisionExactExamples(): array
public static function divisionExactExamples(): array
{
return [
[6, 3, '2'],
Expand All @@ -352,7 +352,7 @@ public function divisionExactExamples(): array
* numeric-string
* }>
*/
public function ceilExamples(): array
public static function ceilExamples(): array
{
return [
[1.2, '2'],
Expand All @@ -367,7 +367,7 @@ public function ceilExamples(): array
* numeric-string
* }>
*/
public function floorExamples(): array
public static function floorExamples(): array
{
return [
[2.7, '2'],
Expand All @@ -382,7 +382,7 @@ public function floorExamples(): array
* numeric-string
* }>
*/
public function absoluteExamples(): array
public static function absoluteExamples(): array
{
return [
[2, '2'],
Expand All @@ -398,7 +398,7 @@ public function absoluteExamples(): array
* numeric-string
* }>
*/
public function shareExamples(): array
public static function shareExamples(): array
{
return [
[10, 2, 4, '5'],
Expand All @@ -408,7 +408,7 @@ public function shareExamples(): array
/**
* @psalm-return array<int,array<int|numeric-string>>
*/
public function compareLessExamples(): array
public static function compareLessExamples(): array
{
return [
[0, 1],
Expand All @@ -427,7 +427,7 @@ public function compareLessExamples(): array
* int|numeric-string
* }>
*/
public function compareEqualExamples(): array
public static function compareEqualExamples(): array
{
return [
[1, 1],
Expand All @@ -443,7 +443,7 @@ public function compareEqualExamples(): array
* numeric-string
* }>
*/
public function modExamples(): array
public static function modExamples(): array
{
return [
[11, 5, '1'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Calculator/GmpCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function it_divides_bug538(): void
/**
* @psalm-return array<int,array<int|numeric-string>>
*/
public function compareLessExamples(): array
public static function compareLessExamples(): array
{
return array_merge(
parent::compareLessExamples(),
Expand Down
2 changes: 1 addition & 1 deletion tests/ConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion tests/Currencies/CryptoCurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function itIsIterable(): void
/**
* @psalm-return non-empty-list<array{non-empty-string}>
*/
public function currencyCodeExamples(): array
public static function currencyCodeExamples(): array
{
/** @psalm-var non-empty-array<non-empty-string, array> $currencies */
$currencies = require __DIR__ . '/../../resources/binance.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/Currencies/CurrencyListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function itIsIterable(): void
}

/** @psalm-return non-empty-list<array{non-empty-string}> */
public function currencyCodeExamples(): array
public static function currencyCodeExamples(): array
{
$currencies = array_keys(self::CORRECT_CURRENCIES);

Expand Down
2 changes: 1 addition & 1 deletion tests/Currencies/ISOCurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function itIsIterable(): void
/**
* @psalm-return non-empty-list<array{non-empty-string}>
*/
public function currencyCodeExamples(): array
public static function currencyCodeExamples(): array
{
/** @psalm-var non-empty-array<non-empty-string, array> $currencies */
$currencies = require __DIR__ . '/../../resources/currency.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/Exchange/SwapExchangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Formatter/BitcoinMoneyFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion tests/MoneyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function itCreatesMoneyUsingFactories(Currency $currency): void
}

/** @psalm-return list<array{Currency}> */
public function currencyExamples(): array
public static function currencyExamples(): array
{
$currencies = new AggregateCurrencies([
new ISOCurrencies(),
Expand Down
Loading

0 comments on commit 4c67318

Please sign in to comment.