mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-31 04:28:51 +00:00
70b4ecd4d3
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.
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AddressTest extends TestCase
|
|
{
|
|
#[DataProvider('providerADDRESS')]
|
|
public function testADDRESS(mixed $expectedResult, mixed ...$args): void
|
|
{
|
|
$result = LookupRef\Address::cell(...$args);
|
|
self::assertEquals($expectedResult, $result);
|
|
}
|
|
|
|
public static function providerADDRESS(): array
|
|
{
|
|
return require 'tests/data/Calculation/LookupRef/ADDRESS.php';
|
|
}
|
|
|
|
#[DataProvider('providerAddressArray')]
|
|
public function testAddressArray(array $expectedResult, string $argument1, string $argument2): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=ADDRESS({$argument1}, {$argument2}, 4)";
|
|
$result = $calculation->calculateFormula($formula);
|
|
self::assertSame($expectedResult, $result);
|
|
}
|
|
|
|
public static function providerAddressArray(): array
|
|
{
|
|
return [
|
|
'row/column vectors' => [
|
|
[['A1', 'B1', 'C1'], ['A2', 'B2', 'C2'], ['A3', 'B3', 'C3']],
|
|
'{1; 2; 3}',
|
|
'{1, 2, 3}',
|
|
],
|
|
];
|
|
}
|
|
}
|