diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c515a6a..29c49b3 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.3'] + php-version: ['8.3', '8.4'] steps: - uses: actions/checkout@v3 @@ -22,7 +22,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, intl, bcmath + extensions: mbstring, intl, bcmath, apcu coverage: pcov - name: Composer install @@ -32,14 +32,13 @@ jobs: - name: Run PHPUnit run: | - if [[ ${{ matrix.php-version }} == '8.1' ]]; then + if [[ ${{ matrix.php-version }} == '8.2' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Code Coverage Report - if: success() && matrix.php-version == '8.1' uses: codecov/codecov-action@v1 validation: @@ -52,8 +51,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' - extensions: mbstring, intl, bcmath + php-version: '8.3' + extensions: mbstring, intl, bcmath, apcu coverage: none - name: Composer Install diff --git a/README.md b/README.md index dea3aad..184e7e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://github.com/spryker/decimal-object/workflows/CI/badge.svg?branch=master)](https://github.com/spryker/decimal-object/actions?query=workflow%3ACI+branch%3Amaster) [![codecov](https://codecov.io/gh/spryker/decimal-object/branch/master/graph/badge.svg?token=L1thFB9nOG)](https://codecov.io/gh/spryker/decimal-object) [![Latest Stable Version](https://poser.pugx.org/spryker/decimal-object/v/stable.svg)](https://packagist.org/packages/spryker/decimal-object) -[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/) +[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.3-8892BF.svg)](https://php.net/) [![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://phpstan.org/) [![License](https://poser.pugx.org/spryker/decimal-object/license)](https://packagist.org/packages/spryker/decimal-object) diff --git a/composer.json b/composer.json index 86f99ae..75a7d40 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,12 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-bcmath": "*", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "^9.5.0", + "phpunit/phpunit": "^12.1.0", "spryker/code-sniffer": "@stable", "phpstan/phpstan": "^1.0.0" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ebf785d..f14a6c4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,6 @@ > - diff --git a/tests/DecimalTest.php b/tests/DecimalTest.php index 21013b0..eb26418 100644 --- a/tests/DecimalTest.php +++ b/tests/DecimalTest.php @@ -24,6 +24,7 @@ class DecimalTest extends TestCase * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('baseProvider')] public function testNewObject($value, string $expected): void { $decimal = new Decimal($value); @@ -51,6 +52,7 @@ public function testNewObjectScientific(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('baseProvider')] public function testCreate($value, string $expected): void { $decimal = Decimal::create($value); @@ -60,7 +62,7 @@ public function testCreate($value, string $expected): void /** * @return array */ - public function baseProvider(): array + public static function baseProvider(): array { $objectWithToStringMethod = new class { @@ -111,6 +113,7 @@ public function __toString(): string * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidValuesProvider')] public function testNewObjectWithInvalidValueThrowsException($value): void { $this->expectException(InvalidArgumentException::class); @@ -121,7 +124,7 @@ public function testNewObjectWithInvalidValueThrowsException($value): void /** * @return array */ - public function invalidValuesProvider(): array + public static function invalidValuesProvider(): array { return [ 'invalid string' => ['xyz'], @@ -141,6 +144,7 @@ public function invalidValuesProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('truncateProvider')] public function testTruncate($input, int $scale, string $expected): void { $decimal = Decimal::create($input); @@ -150,7 +154,7 @@ public function testTruncate($input, int $scale, string $expected): void /** * @return array */ - public function truncateProvider(): array + public static function truncateProvider(): array { return [ [0, 0, '0'], @@ -170,6 +174,7 @@ public function truncateProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('integerProvider')] public function testIsInteger($value, bool $expected): void { $decimal = Decimal::create($value); @@ -179,7 +184,7 @@ public function testIsInteger($value, bool $expected): void /** * @return array */ - public function integerProvider(): array + public static function integerProvider(): array { return [ [5, true], @@ -203,6 +208,7 @@ public function integerProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('zeroProvider')] public function testIsZero($value, bool $expected): void { $decimal = Decimal::create($value); @@ -212,7 +218,7 @@ public function testIsZero($value, bool $expected): void /** * @return array */ - public function zeroProvider(): array + public static function zeroProvider(): array { return [ [5, false], @@ -235,6 +241,7 @@ public function zeroProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareZeroProvider')] public function testIsPositive($input, int $expected): void { $decimal = Decimal::create($input); @@ -249,6 +256,7 @@ public function testIsPositive($input, int $expected): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareZeroProvider')] public function testIsNegative($input, int $expected): void { $decimal = Decimal::create($input); @@ -258,7 +266,7 @@ public function testIsNegative($input, int $expected): void /** * @return array */ - public function compareZeroProvider(): array + public static function compareZeroProvider(): array { return [ [0, 0], @@ -284,6 +292,7 @@ public function compareZeroProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('scaleProvider')] public function testScale($input, int $expected): void { $decimal = Decimal::create($input); @@ -293,7 +302,7 @@ public function testScale($input, int $expected): void /** * @return array */ - public function scaleProvider(): array + public static function scaleProvider(): array { return [ [0, 0], @@ -316,6 +325,7 @@ public function scaleProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('scientificProvider')] public function testToScientific($value, string $expected): void { $decimal = Decimal::create($value); @@ -327,7 +337,7 @@ public function testToScientific($value, string $expected): void /** * @return array */ - public function scientificProvider(): array + public static function scientificProvider(): array { return [ ['-23', '-2.3e1'], @@ -390,12 +400,13 @@ public function testToFloat(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('bigFloatDataProvider')] public function testToFloatForBigDecimalThrowsAnException(string $value): void { $decimal = Decimal::create($value); $this->expectException(TypeError::class); - $this->expectErrorMessage('Cannot cast Big Decimal to Float'); + $this->expectExceptionMessage('Cannot cast Big Decimal to Float'); $result = $decimal->toFloat(); } @@ -403,7 +414,7 @@ public function testToFloatForBigDecimalThrowsAnException(string $value): void /** * @return array */ - public function bigFloatDataProvider(): array + public static function bigFloatDataProvider(): array { return [ 'positive' => ['2.6' . PHP_INT_MAX], @@ -430,12 +441,13 @@ public function testToInt(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('bigIntDataProvider')] public function testToIntForBigIntThrowsAnException(string $value): void { $decimal = Decimal::create($value); $this->expectException(TypeError::class); - $this->expectErrorMessage('Cannot cast Big Integer to Integer'); + $this->expectExceptionMessage('Cannot cast Big Integer to Integer'); $decimal->toInt(); } @@ -443,7 +455,7 @@ public function testToIntForBigIntThrowsAnException(string $value): void /** * @return array */ - public function bigIntDataProvider(): array + public static function bigIntDataProvider(): array { return [ 'positive' => ['9' . PHP_INT_MAX], @@ -586,6 +598,7 @@ public function testEquals(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('roundProvider')] public function testRound($value, int $scale, string $expected): void { $decimal = Decimal::create($value); @@ -609,7 +622,7 @@ protected function assertNativeRound(string $expected, $value, int $scale, int $ /** * @return array */ - public function roundProvider(): array + public static function roundProvider(): array { return [ [0, 0, '0'], @@ -637,6 +650,7 @@ public function roundProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('floorProvider')] public function testFloor($value, string $expected): void { $decimal = Decimal::create($value); @@ -658,7 +672,7 @@ protected function assertNativeFloor(string $expected, $value): void /** * @return array */ - public function floorProvider(): array + public static function floorProvider(): array { return [ [0, '0'], @@ -684,6 +698,7 @@ public function floorProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('ceilProvider')] public function testCeil($value, string $expected): void { $decimal = Decimal::create($value); @@ -705,7 +720,7 @@ protected function assertNativeCeil(string $expected, $value): void /** * @return array */ - public function ceilProvider(): array + public static function ceilProvider(): array { return [ [0, '0'], @@ -732,6 +747,7 @@ public function ceilProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testGreaterThan($a, $b, int $expected): void { $decimal = Decimal::create($a); @@ -747,6 +763,7 @@ public function testGreaterThan($a, $b, int $expected): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testLessThan($a, $b, int $expected): void { $decimal = Decimal::create($a); @@ -762,6 +779,7 @@ public function testLessThan($a, $b, int $expected): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testGreaterEquals($a, $b, int $expected): void { $decimal = Decimal::create($a); @@ -777,6 +795,7 @@ public function testGreaterEquals($a, $b, int $expected): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('compareProvider')] public function testLessEquals($a, $b, int $expected): void { $decimal = Decimal::create($a); @@ -786,7 +805,7 @@ public function testLessEquals($a, $b, int $expected): void /** * @return array */ - public function compareProvider(): array + public static function compareProvider(): array { return [ [0, 0, 0], @@ -842,6 +861,7 @@ public function testSubtract(): void * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('multiplicationProvider')] public function testMultiply($a, $b, ?int $scale, string $expected): void { $decimal = Decimal::create($a); @@ -851,7 +871,7 @@ public function testMultiply($a, $b, ?int $scale, string $expected): void /** * @return array */ - public function multiplicationProvider(): array + public static function multiplicationProvider(): array { return [ ['0', '0', null, '0'], @@ -882,6 +902,7 @@ public function multiplicationProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('multiplicationLegacyProvider')] public function testMultiplyLegacy($a, $b, ?int $scale, string $expected): void { $decimal = Decimal::create($a); @@ -891,7 +912,7 @@ public function testMultiplyLegacy($a, $b, ?int $scale, string $expected): void /** * @return array */ - public function multiplicationLegacyProvider(): array + public static function multiplicationLegacyProvider(): array { return [ ['0', '0', 3, version_compare(PHP_VERSION, '7.3') < 0 ? '0' : '0.000'], @@ -908,6 +929,7 @@ public function multiplicationLegacyProvider(): array * * @return void */ + #[\PHPUnit\Framework\Attributes\DataProvider('divisionProvider')] public function testDivide($a, $b, int $scale, string $expected): void { $decimal = Decimal::create($a); @@ -917,7 +939,7 @@ public function testDivide($a, $b, int $scale, string $expected): void /** * @return array */ - public function divisionProvider(): array + public static function divisionProvider(): array { return [ ['0', '1', 0, '0'],