From 3e0959e478ef3fe17f9f74ea874cf1e942dec54c Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Mon, 14 Sep 2026 13:42:38 +0200 Subject: [PATCH] Allow PHPUnit 12 and 13 --- .github/workflows/ci.yml | 4 +-- composer.json | 2 +- phpunit.xml.dist | 1 - tests/DecimalTest.php | 66 ++++++++++++++-------------------------- 4 files changed, 24 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40d5ead..191fdc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.1', '8.4'] + php-version: ['8.1', '8.3', '8.5'] steps: - uses: actions/checkout@v4 @@ -26,13 +26,11 @@ jobs: coverage: pcov - name: Composer install - continue-on-error: ${{ matrix.php-version == '8.3' }} run: | composer --version composer install - name: Run PHPUnit - continue-on-error: ${{ matrix.php-version == '8.3' }} run: | if [[ ${{ matrix.php-version }} == '8.1' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml diff --git a/composer.json b/composer.json index c168dc2..ae80adf 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require-dev": { "php-collective/code-sniffer": "^0.2.1", "phpstan/phpstan": "^2.0.0", - "phpunit/phpunit": "^10.5.45 || ^11.0.0" + "phpunit/phpunit": "^10.5.45 || ^11.0.0 || ^12.0.0 || ^13.0.0" }, "minimum-stability": "stable", "prefer-stable": true, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3542715..ef3d67a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,6 @@ > - diff --git a/tests/DecimalTest.php b/tests/DecimalTest.php index 864678c..7ba553f 100644 --- a/tests/DecimalTest.php +++ b/tests/DecimalTest.php @@ -19,13 +19,12 @@ class DecimalTest extends TestCase { /** - * @dataProvider baseProvider - * * @param mixed $value * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('baseProvider')] public function testNewObject(mixed $value, string $expected): void { $decimal = new Decimal($value); @@ -46,13 +45,12 @@ public function testNewObjectScientific(): void } /** - * @dataProvider baseProvider - * * @param mixed $value * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('baseProvider')] public function testCreate(mixed $value, string $expected): void { $decimal = Decimal::create($value); @@ -140,12 +138,11 @@ public function __toString(): string } /** - * @dataProvider invalidValuesProvider - * * @param mixed $value * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidValuesProvider')] public function testNewObjectWithInvalidValueThrowsException(mixed $value): void { $this->expectException(InvalidArgumentException::class); @@ -166,14 +163,13 @@ public static function invalidValuesProvider(): array } /** - * @dataProvider truncateProvider - * * @param mixed $input * @param int $scale * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('truncateProvider')] public function testTruncate(mixed $input, int $scale, string $expected): void { $decimal = Decimal::create($input); @@ -196,13 +192,12 @@ public static function truncateProvider(): array } /** - * @dataProvider integerProvider - * * @param mixed $value * @param bool $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('integerProvider')] public function testIsInteger(mixed $value, bool $expected): void { $decimal = Decimal::create($value); @@ -229,13 +224,12 @@ public static function integerProvider(): array } /** - * @dataProvider zeroProvider - * * @param mixed $value * @param bool $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('zeroProvider')] public function testIsZero(mixed $value, bool $expected): void { $decimal = Decimal::create($value); @@ -261,13 +255,12 @@ public static function zeroProvider(): array } /** - * @dataProvider compareZeroProvider - * * @param mixed $input * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareZeroProvider')] public function testIsPositive(mixed $input, int $expected): void { $decimal = Decimal::create($input); @@ -275,13 +268,12 @@ public function testIsPositive(mixed $input, int $expected): void } /** - * @dataProvider compareZeroProvider - * * @param mixed $input * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareZeroProvider')] public function testIsNegative(mixed $input, int $expected): void { $decimal = Decimal::create($input); @@ -310,13 +302,12 @@ public static function compareZeroProvider(): array } /** - * @dataProvider scaleProvider - * * @param mixed $input * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('scaleProvider')] public function testScale(mixed $input, int $expected): void { $decimal = Decimal::create($input); @@ -342,13 +333,12 @@ public static function scaleProvider(): array } /** - * @dataProvider scientificProvider - * * @param mixed $value * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('scientificProvider')] public function testToScientific(mixed $value, string $expected): void { $decimal = Decimal::create($value); @@ -417,12 +407,11 @@ public function testToFloat(): void } /** - * @dataProvider bigFloatDataProvider - * * @param string $value * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('bigFloatDataProvider')] public function testToFloatForBigDecimalThrowsAnException(string $value): void { $decimal = Decimal::create($value); @@ -457,12 +446,11 @@ public function testToInt(): void } /** - * @dataProvider bigIntDataProvider - * * @param string $value * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('bigIntDataProvider')] public function testToIntForBigIntThrowsAnException(string $value): void { $decimal = Decimal::create($value); @@ -611,14 +599,13 @@ public function testEquals(): void } /** - * @dataProvider roundProvider - * * @param mixed $value * @param int $scale * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('roundProvider')] public function testRound(mixed $value, int $scale, string $expected): void { $decimal = Decimal::create($value); @@ -672,13 +659,12 @@ public static function roundProvider(): array } /** - * @dataProvider floorProvider - * * @param mixed $value * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('floorProvider')] public function testFloor(mixed $value, string $expected): void { $decimal = Decimal::create($value); @@ -726,13 +712,12 @@ public static function floorProvider(): array } /** - * @dataProvider ceilProvider - * * @param mixed $value * @param string $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('ceilProvider')] public function testCeil(mixed $value, string $expected): void { $decimal = Decimal::create($value); @@ -779,14 +764,13 @@ public static function ceilProvider(): array } /** - * @dataProvider compareProvider - * * @param mixed $a * @param mixed $b * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testGreaterThan(mixed $a, mixed $b, int $expected): void { $decimal = Decimal::create($a); @@ -794,14 +778,13 @@ public function testGreaterThan(mixed $a, mixed $b, int $expected): void } /** - * @dataProvider compareProvider - * * @param mixed $a * @param mixed $b * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testLessThan(mixed $a, mixed $b, int $expected): void { $decimal = Decimal::create($a); @@ -809,14 +792,13 @@ public function testLessThan(mixed $a, mixed $b, int $expected): void } /** - * @dataProvider compareProvider - * * @param mixed $a * @param mixed $b * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testGreaterEquals(mixed $a, mixed $b, int $expected): void { $decimal = Decimal::create($a); @@ -824,14 +806,13 @@ public function testGreaterEquals(mixed $a, mixed $b, int $expected): void } /** - * @dataProvider compareProvider - * * @param mixed $a * @param mixed $b * @param int $expected * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testLessEquals(mixed $a, mixed $b, int $expected): void { $decimal = Decimal::create($a); @@ -888,8 +869,6 @@ public function testSubtract(): void } /** - * @dataProvider multiplicationProvider - * * @param mixed $a * @param mixed $b * @param int|null $scale @@ -897,6 +876,7 @@ public function testSubtract(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('multiplicationProvider')] public function testMultiply(mixed $a, mixed $b, ?int $scale, string $expected): void { $decimal = Decimal::create($a); @@ -928,8 +908,6 @@ public static function multiplicationProvider(): array } /** - * @dataProvider multiplicationLegacyProvider - * * @param mixed $a * @param mixed $b * @param int|null $scale @@ -937,6 +915,7 @@ public static function multiplicationProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('multiplicationLegacyProvider')] public function testMultiplyLegacy(mixed $a, mixed $b, ?int $scale, string $expected): void { $decimal = Decimal::create($a); @@ -954,8 +933,6 @@ public static function multiplicationLegacyProvider(): array } /** - * @dataProvider divisionProvider - * * @param mixed $a * @param mixed $b * @param int $scale @@ -963,6 +940,7 @@ public static function multiplicationLegacyProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('divisionProvider')] public function testDivide(mixed $a, mixed $b, int $scale, string $expected): void { $decimal = Decimal::create($a);