mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +00:00
95b8c4d59b
* Continue MathTrig Breakup - Completion! Continuing the process of breaking MathTrip.php up into smaller classes. This round takes care of everything that was left: - ABS - DEGREES - EXP - RADIANS - SQRT - SQRTPI - SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2 The only notable logic change was that the 3 SUMX* functions had accepted arrays of unlike length; in that condition, they now return N/A, as Excel does. There had been no tests for this condition. All the functions in MathTrig.php are now deprecated. Except for COMBIN, the test suite executes them only from MathTrig MovedFunctionsTest. COMBIN is still directly called by some Statistics Binomial functions which have not yet had the opportunity to be re-coded for the new location. Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
|
|
|
class SumXMY2Test extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerSUMXMY2
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testSUMXMY2($expectedResult, array $matrixData1, array $matrixData2): void
|
|
{
|
|
$this->mightHaveException($expectedResult);
|
|
$sheet = $this->sheet;
|
|
$maxRow = 0;
|
|
$funcArg1 = '';
|
|
foreach (Functions::flattenArray($matrixData1) as $arg) {
|
|
++$maxRow;
|
|
$funcArg1 = "A1:A$maxRow";
|
|
$this->setCell("A$maxRow", $arg);
|
|
}
|
|
$maxRow = 0;
|
|
$funcArg2 = '';
|
|
foreach (Functions::flattenArray($matrixData2) as $arg) {
|
|
++$maxRow;
|
|
$funcArg2 = "C1:C$maxRow";
|
|
$this->setCell("C$maxRow", $arg);
|
|
}
|
|
$sheet->getCell('B1')->setValue("=SUMXMY2($funcArg1, $funcArg2)");
|
|
$result = $sheet->getCell('B1')->getCalculatedValue();
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
|
|
}
|
|
|
|
public function providerSUMXMY2()
|
|
{
|
|
return require 'tests/data/Calculation/MathTrig/SUMXMY2.php';
|
|
}
|
|
}
|