Files
oleibman 70b4ecd4d3 Use calculateFormula Rather Than _calculateFormulaValue in Tests
They aren't quite interchangeable. Both are used in the test suite, with no indication of why one or the other. I think we'd be best off being consistent. Based on the names, I think `_calculateFormulaValue` was intended as a private, or at least internal, method, so favor `calculateFormula`. I do not intend to rename or re-categorize `_calculateFormulaValue`, just remove its usage when it isn't clearly warranted.
2025-11-13 20:48:46 -08:00

46 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
class RomanTest extends AllSetupTeardown
{
#[\PHPUnit\Framework\Attributes\DataProvider('providerROMAN')]
public function testROMAN(string $expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->getSheet();
$sheet->setCellValue('A3', 49);
$sheet->getCell('A1')->setValue("=ROMAN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEquals($expectedResult, $result);
}
public static function providerROMAN(): array
{
return require 'tests/data/Calculation/MathTrig/ROMAN.php';
}
#[\PHPUnit\Framework\Attributes\DataProvider('providerRomanArray')]
public function testRomanArray(array $expectedResult, string $values, string $styles): void
{
$calculation = Calculation::getInstance();
$formula = "=ROMAN({$values}, {$styles})";
$result = $calculation->calculateFormula($formula);
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
}
public static function providerRomanArray(): array
{
return [
'row vector' => [[['XLIX', 'MMXXII', 'CDXCIX']], '{49, 2022, 499}', '0'],
'column vector' => [[['XLIX'], ['MMXXII'], ['CDXCIX']], '{49; 2022; 499}', '0'],
'matrix' => [[['XLIX', 'MMXXII'], ['LXIV', 'CDXCIX']], '{49, 2022; 64, 499}', '0'],
];
}
}