Skip to content

Commit

Permalink
Upgrade to PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Nov 26, 2023
1 parent e95cbcd commit 7947862
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/vendor
/composer.lock
/.phpunit.result.cache
/.phpunit.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ext-pdo": "*",
"brick/varexporter": "~0.3.0",
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^9.4.3",
"phpunit/phpunit": "^10.1",
"vimeo/psalm": "5.14.1"
},
"suggest": {
Expand Down
9 changes: 5 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Money tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Context/AutoContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testApplyTo(string $amount, string $currency, RoundingMode $roun
}
}

public function providerApplyTo() : array
public static function providerApplyTo() : array
{
return [
['1', 'USD', RoundingMode::UNNECESSARY, '1'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Context/CashContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testApplyTo(int $step, string $amount, string $currency, Roundin
}
}

public function providerApplyTo() : array
public static function providerApplyTo() : array
{
return [
[1, '1', 'USD', RoundingMode::UNNECESSARY, '1.00'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Context/CustomContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testApplyTo(int $scale, int $step, string $amount, string $curre
}
}

public function providerApplyTo() : array
public static function providerApplyTo() : array
{
return [
[2, 1, '1', 'USD', RoundingMode::UNNECESSARY, '1.00'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Context/DefaultContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testApplyTo(string $amount, string $currency, RoundingMode $roun
}
}

public function providerApplyTo() : array
public static function providerApplyTo() : array
{
return [
['1', 'USD', RoundingMode::UNNECESSARY, '1.00'],
Expand Down
8 changes: 4 additions & 4 deletions tests/CurrencyConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testConvertMoney(array $money, string $toCurrency, RoundingMode
}
}

public function providerConvertMoney() : array
public static function providerConvertMoney() : array
{
return [
[['1.23', 'EUR'], 'USD', RoundingMode::DOWN, 'USD 1.35'],
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testConvertMoneyBag(array $monies, string $currency, Context $co
$this->assertMoneyIs($total, $currencyConverter->convert($moneyBag, $currency, $context, $roundingMode));
}

public function providerConvertMoneyBag() : array
public static function providerConvertMoneyBag() : array
{
return [
[[['354.40005', 'EUR'], ['3.1234', 'JPY']], 'USD', new DefaultContext(), RoundingMode::DOWN, 'USD 437.56'],
Expand Down Expand Up @@ -138,7 +138,7 @@ public function testConvertMoneyBagToRational(array $monies, string $currency, s
$this->assertRationalMoneyEquals($expectedTotal, $actualTotal);
}

public function providerConvertMoneyBagToRational() : array
public static function providerConvertMoneyBagToRational() : array
{
return [
[[['354.40005', 'EUR'], ['3.1234', 'JPY']], 'USD', 'USD 19909199529475444524673813/50000000000000000000000'],
Expand Down Expand Up @@ -171,7 +171,7 @@ public function testConvertRationalMoney(array $money, string $toCurrency, Round
}
}

public function providerConvertRationalMoney() : array
public static function providerConvertRationalMoney() : array
{
return [
[['7/9', 'USD'], 'EUR', RoundingMode::DOWN, 'EUR 0.70'],
Expand Down
8 changes: 4 additions & 4 deletions tests/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testOf(string $currencyCode, int $numericCode, int $fractionDigi
$this->assertCurrencyEquals($currencyCode, $numericCode, $name, $fractionDigits, $currency);
}

public function providerOf() : array
public static function providerOf() : array
{
return [
['USD', 840, 2, 'US Dollar'],
Expand All @@ -49,7 +49,7 @@ public function testOfUnknownCurrencyCode(string|int $currencyCode) : void
Currency::of($currencyCode);
}

public function providerOfUnknownCurrencyCode() : array
public static function providerOfUnknownCurrencyCode() : array
{
return [
['XXX'],
Expand Down Expand Up @@ -85,7 +85,7 @@ public function testOfCountry(string $countryCode, string $expected) : void
}
}

public function providerOfCountry() : array
public static function providerOfCountry() : array
{
return [
['CA', 'CAD'],
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testJsonSerialize(Currency $currency, string $expected): void
self::assertSame(json_encode($expected), json_encode($currency));
}

public function providerJsonSerialize(): array
public static function providerJsonSerialize(): array
{
return [
[Currency::of('USD'), 'USD']
Expand Down
4 changes: 2 additions & 2 deletions tests/ExchangeRateProvider/BaseCurrencyProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testGetExchangeRate(string $sourceCurrencyCode, string $targetCu
self::assertSame($exchangeRate, (string) $rate->toScale(6, RoundingMode::DOWN));
}

public function providerGetExchangeRate() : array
public static function providerGetExchangeRate() : array
{
return [
['USD', 'EUR', '0.900000'],
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testReturnBigNumber(BigNumber|float|int|string $rate) : void
$this->assertInstanceOf(BigNumber::class, $rate);
}

public function providerReturnBigNumber() : array
public static function providerReturnBigNumber() : array
{
return [[1], [1.1], ['1.0'], [BigNumber::of('1')]];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ExchangeRateProvider/ConfigurableProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetExchangeRate(string $sourceCurrencyCode, string $targetCu
self::assertSame($exchangeRate, (string) BigRational::of($rate)->toScale(3, RoundingMode::DOWN));
}

public function providerGetExchangeRate() : array
public static function providerGetExchangeRate() : array
{
return [
['USD', 'EUR', '0.800'],
Expand Down
10 changes: 5 additions & 5 deletions tests/ExchangeRateProvider/PDOProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testConfigurationConstructorThrows(Closure $getConfiguration, st
$getConfiguration();
}

public function providerConstructorWithInvalidConfiguration() : array
public static function providerConstructorWithInvalidConfiguration() : array
{
return [
[fn () => new PDOProviderConfiguration(
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testGetExchangeRate(string $sourceCurrencyCode, string $targetCu
}
}

public function providerGetExchangeRate() : array
public static function providerGetExchangeRate() : array
{
return [
['USD', 'EUR', 0.9],
Expand Down Expand Up @@ -165,7 +165,7 @@ public function testWithFixedSourceCurrency(string $sourceCurrencyCode, string $
}
}

public function providerWithFixedSourceCurrency() : array
public static function providerWithFixedSourceCurrency() : array
{
return [
['EUR', 'USD', 1.1],
Expand Down Expand Up @@ -219,7 +219,7 @@ public function testWithFixedTargetCurrency(string $sourceCurrencyCode, string $
}
}

public function providerWithFixedTargetCurrency() : array
public static function providerWithFixedTargetCurrency() : array
{
return [
['USD', 'EUR', 0.9],
Expand Down Expand Up @@ -281,7 +281,7 @@ public function testWithParameters(string $sourceCurrencyCode, string $targetCur
}
}

public function providerWithParameters() : array
public static function providerWithParameters() : array
{
return [
['EUR', 'USD', [2017, 8], 1.1],
Expand Down
4 changes: 2 additions & 2 deletions tests/ISOCurrencyProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetCurrency(string $currencyCode, int $numericCode, string $
$this->assertCurrencyEquals($currencyCode, $numericCode, $name, $defaultFractionDigits, $currency);
}

public function providerGetCurrency() : array
public static function providerGetCurrency() : array
{
return [
['EUR', 978, 'Euro', 2],
Expand All @@ -66,7 +66,7 @@ public function testGetUnknownCurrency(string|int $currencyCode) : void
ISOCurrencyProvider::getInstance()->getCurrency($currencyCode);
}

public function providerUnknownCurrency() : array
public static function providerUnknownCurrency() : array
{
return [
['XXX'],
Expand Down
6 changes: 3 additions & 3 deletions tests/MoneyComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testCompare(array $a, array $b, int|string $cmp) : void
self::assertSame($cmp === 0, $comparator->isEqual($a, $b));
}

public function providerCompare() : array
public static function providerCompare() : array
{
return [
[['1.00', 'EUR'], ['1', 'EUR'], 0],
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testMin(array $monies, string $expectedMin) : void
}
}

public function providerMin() : array
public static function providerMin() : array
{
return [
[[['1.00', 'EUR'], ['1.09', 'USD']], 'USD 1.09'],
Expand Down Expand Up @@ -149,7 +149,7 @@ public function testMax(array $monies, string $expectedMin) : void
}
}

public function providerMax() : array
public static function providerMax() : array
{
return [
[[['1.00', 'EUR'], ['1.09', 'USD']], 'EUR 1.00'],
Expand Down
Loading

0 comments on commit 7947862

Please sign in to comment.