mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-03 05:57:46 +00:00
704a7b9fd1
* Fix Unintential Deprecated Calls in Tests - LOOKUPREF I think it's best to install these before PR #3166. There are no changes to source code, only to test members which continue to inadvertently use calls to deprecated functions. * Fix deprecation DocBlocks Deprecated->deprecated, adjust see and comments * One Intentional Deprecation Annotate it.
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ChooseTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerCHOOSE
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testCHOOSE($expectedResult, ...$args): void
|
|
{
|
|
$result = LookupRef\Selection::choose(...$args);
|
|
self::assertEquals($expectedResult, $result);
|
|
}
|
|
|
|
public function providerCHOOSE(): array
|
|
{
|
|
return require 'tests/data/Calculation/LookupRef/CHOOSE.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerChooseArray
|
|
*/
|
|
public function testChooseArray(array $expectedResult, string $values, array $selections): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$selections = implode(',', $selections);
|
|
$formula = "=CHOOSE({$values}, {$selections})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertEquals($expectedResult, $result);
|
|
}
|
|
|
|
public function providerChooseArray(): array
|
|
{
|
|
return [
|
|
'row vector' => [
|
|
[['Orange', 'Blue', 'Yellow']],
|
|
'{2, 5, 3}',
|
|
['"Red"', '"Orange"', '"Yellow"', '"Green"', '"Blue"'],
|
|
],
|
|
];
|
|
}
|
|
}
|