Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jan 20, 2021
1 parent a1c7e0e commit 25e372b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ jobs:
CALCULATOR: ${{ matrix.calculator }}
if: ${{ matrix.php-version == '8.0' }}

- name: Run PHPUnit with bcscale()
run: vendor/bin/phpunit
env:
CALCULATOR: BCMath
BCMATH_DEFAULT_SCALE: 8
if: ${{ matrix.calculator == 'BCMath' }}

- name: Upload coverage report to Coveralls
run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
env:
Expand Down
7 changes: 7 additions & 0 deletions phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ function getCalculatorImplementation()
}

Calculator::set(getCalculatorImplementation());

$scale = \getenv('BCMATH_DEFAULT_SCALE');

if ($scale !== false) {
echo "Using bcscale($scale)", PHP_EOL;
\bcscale((int) $scale);
}
17 changes: 0 additions & 17 deletions tests/BigDecimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Brick\Math\Exception\NegativeNumberException;
use Brick\Math\Exception\NumberFormatException;
use Brick\Math\Exception\RoundingNecessaryException;
use Brick\Math\Internal\Calculator;
use Brick\Math\RoundingMode;

/**
Expand Down Expand Up @@ -848,22 +847,6 @@ public function testExactlyDividedByZero() : void
BigDecimal::of(1)->exactlyDividedBy(0);
}

public function testExactlyDividedByWithNonZeroBcMathDefaultScale(): void
{
if (! Calculator::get() instanceof Calculator\BcMathCalculator) {
self::markTestSkipped('This test targets the BCMath calculator only.');
}

$previousScale = bcscale();
bcscale(8);

try {
self::assertSame('0.1', (string) BigDecimal::of(1)->exactlyDividedBy(10));
} finally {
bcscale($previousScale);
}
}

/**
* @dataProvider providerDividedByWithRoundingNecessaryThrowsException
*
Expand Down

0 comments on commit 25e372b

Please sign in to comment.