From e580f10c4666340ac3499b2c72ec4a32f84b0814 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 17 Feb 2022 19:37:40 +0100 Subject: [PATCH] Unit test some basic arra-formula chaining (#2599) --- .../Calculation/ArrayFormulaTest.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php diff --git a/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php b/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php new file mode 100644 index 00000000..fcbe017e --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php @@ -0,0 +1,60 @@ +compatibilityMode = Functions::getCompatibilityMode(); + $calculation = Calculation::getInstance(); + $this->locale = $calculation->getLocale(); + Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + } + + protected function tearDown(): void + { + Functions::setCompatibilityMode($this->compatibilityMode); + $calculation = Calculation::getInstance(); + $calculation->setLocale($this->locale); + } + + /** + * @dataProvider providerArrayFormulae + * + * @param mixed $expectedResult + */ + public function testArrayFormula(string $formula, $expectedResult): void + { + $result = Calculation::getInstance()->_calculateFormulaValue($formula); + self::assertEquals($expectedResult, $result); + } + + public function providerArrayFormulae(): array + { + return [ + [ + '=MAX(ABS({-3, 4, -2; 6, -3, -12}))', + 12, + ], + [ + '=SUM(SEQUENCE(3,3,0,1))', + 36, + ], + ]; + } +}