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>
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
|
|
|
class MMultTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerMMULT
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testMMULT($expectedResult, ...$args): void
|
|
{
|
|
$result = MathTrig\MatrixFunctions::funcMMult(...$args);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
|
}
|
|
|
|
public function providerMMULT()
|
|
{
|
|
return require 'tests/data/Calculation/MathTrig/MMULT.php';
|
|
}
|
|
|
|
public function testOnSpreadsheet(): void
|
|
{
|
|
// very limited ability to test this in the absence of dynamic arrays
|
|
$sheet = $this->sheet;
|
|
$sheet->getCell('A1')->setValue('=MMULT({1,2,3}, {1,2,3})'); // incompatible dimensions
|
|
self::assertSame('#VALUE!', $sheet->getCell('A1')->getCalculatedValue());
|
|
|
|
$sheet->getCell('A11')->setValue('=MMULT({1, 2, 3, 4}, {5; 6; 7; 8})');
|
|
self::assertEquals(70, $sheet->getCell('A11')->getCalculatedValue());
|
|
$sheet->getCell('A2')->setValue(1);
|
|
$sheet->getCell('B2')->setValue(2);
|
|
$sheet->getCell('C2')->setValue(3);
|
|
$sheet->getCell('D2')->setValue(4);
|
|
$sheet->getCell('D3')->setValue(5);
|
|
$sheet->getCell('D4')->setValue(6);
|
|
$sheet->getCell('A12')->setValue('=MMULT(A2:C2,D2:D4)');
|
|
self::assertEquals(32, $sheet->getCell('A12')->getCalculatedValue());
|
|
}
|
|
}
|