Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<ini name="error_reporting" value="32767"/>
</php>

Expand Down
66 changes: 22 additions & 44 deletions tests/DecimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -261,27 +255,25 @@ 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);
$this->assertSame($expected > 0, $decimal->isPositive());
}

/**
* @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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -779,59 +764,55 @@ 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);
$this->assertSame($expected > 0, $decimal->greaterThan($b));
}

/**
* @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);
$this->assertSame($expected < 0, $decimal->lessThan($b));
}

/**
* @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);
$this->assertSame($expected >= 0, $decimal->greaterThanOrEquals($b));
}

/**
* @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);
Expand Down Expand Up @@ -888,15 +869,14 @@ public function testSubtract(): void
}

/**
* @dataProvider multiplicationProvider
*
* @param mixed $a
* @param mixed $b
* @param int|null $scale
* @param string $expected
*
* @return void
*/
#[\PHPUnit\Framework\Attributes\DataProvider('multiplicationProvider')]
public function testMultiply(mixed $a, mixed $b, ?int $scale, string $expected): void
{
$decimal = Decimal::create($a);
Expand Down Expand Up @@ -928,15 +908,14 @@ public static function multiplicationProvider(): array
}

/**
* @dataProvider multiplicationLegacyProvider
*
* @param mixed $a
* @param mixed $b
* @param int|null $scale
* @param string $expected
*
* @return void
*/
#[\PHPUnit\Framework\Attributes\DataProvider('multiplicationLegacyProvider')]
public function testMultiplyLegacy(mixed $a, mixed $b, ?int $scale, string $expected): void
{
$decimal = Decimal::create($a);
Expand All @@ -954,15 +933,14 @@ public static function multiplicationLegacyProvider(): array
}

/**
* @dataProvider divisionProvider
*
* @param mixed $a
* @param mixed $b
* @param int $scale
* @param string $expected
*
* @return void
*/
#[\PHPUnit\Framework\Attributes\DataProvider('divisionProvider')]
public function testDivide(mixed $a, mixed $b, int $scale, string $expected): void
{
$decimal = Decimal::create($a);
Expand Down
Loading