mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-26 19:03:10 +00:00
Clean Up Some Engineering Tests
This came to light while cleaning up ComplexAssert. Many tests are calling `_calculateFormulaValue` rather than `calculateFormula`, and, as a result, have to be trimmed before asserting. This PR changes those calls, and does a bit more to simplify the tests. There are a lot of other non-Engineering tests which call `_calculateFormulaValue`, but none of those need to manipulate the result after the test. This PR changes only tests, no source code.
This commit is contained in:
@@ -7,12 +7,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Engineering\BitWise;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheetTests\Calculation\Functions\FormulaArguments;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BitRShiftTest extends TestCase
|
||||
class BitRShiftTest extends AllSetupTeardown
|
||||
{
|
||||
#[DataProvider('providerBITRSHIFT')]
|
||||
public function testDirectCallToBITRSHIFT(float|int|string $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void
|
||||
@@ -29,7 +27,7 @@ class BitRShiftTest extends TestCase
|
||||
$calculation = Calculation::getInstance();
|
||||
$formula = "=BITRSHIFT({$arguments})";
|
||||
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
$result = $calculation->calculateFormula($formula);
|
||||
self::assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
@@ -38,8 +36,7 @@ class BitRShiftTest extends TestCase
|
||||
{
|
||||
$arguments = new FormulaArguments(...$args);
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
$worksheet = $this->getSheet();
|
||||
$argumentCells = $arguments->populateWorksheet($worksheet);
|
||||
$formula = "=BITRSHIFT({$argumentCells})";
|
||||
|
||||
@@ -47,8 +44,6 @@ class BitRShiftTest extends TestCase
|
||||
->getCell('A1')
|
||||
->getCalculatedValue();
|
||||
self::assertSame($expectedResult, $result);
|
||||
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public static function providerBITRSHIFT(): array
|
||||
@@ -61,8 +56,7 @@ class BitRShiftTest extends TestCase
|
||||
{
|
||||
$arguments = new FormulaArguments(...$args);
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
$worksheet = $this->getSheet();
|
||||
$argumentCells = $arguments->populateWorksheet($worksheet);
|
||||
$formula = "=BITRSHIFT({$argumentCells})";
|
||||
|
||||
@@ -71,8 +65,6 @@ class BitRShiftTest extends TestCase
|
||||
$worksheet->setCellValue('A1', $formula)
|
||||
->getCell('A1')
|
||||
->getCalculatedValue();
|
||||
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public static function providerUnhappyBITRSHIFT(): array
|
||||
@@ -90,7 +82,7 @@ class BitRShiftTest extends TestCase
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$formula = "=BITRSHIFT({$number}, {$bits})";
|
||||
$result = $calculation->_calculateFormulaValue($formula);
|
||||
$result = $calculation->calculateFormula($formula);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user