Files
Adrien Crivelli ec4098c8fd Strict mode for all tests
While we might never be able to have 100% of our code strict, we can at
the very least do it for all of our tests. This ensures that our tests
are using our API with the types as intended by the test author, and not
silently be cast to what our API requires.
2023-09-07 17:44:56 +08:00

44 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
class MMultTest extends AllSetupTeardown
{
/**
* @dataProvider providerMMULT
*/
public function testMMULT(mixed $expectedResult, mixed ...$args): void
{
$result = MathTrig\MatrixFunctions::multiply(...$args);
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
}
public static function providerMMULT(): array
{
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->getSheet();
$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());
}
}