SumSqTest.php 957 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. class SumSqTest extends AllSetupTeardown
  4. {
  5. /**
  6. * @dataProvider providerSUMSQ
  7. *
  8. * @param mixed $expectedResult
  9. */
  10. public function testSUMSQ($expectedResult, ...$args): void
  11. {
  12. $this->mightHaveException($expectedResult);
  13. $maxRow = 0;
  14. $funcArg = '';
  15. $sheet = $this->getSheet();
  16. foreach ($args as $arg) {
  17. ++$maxRow;
  18. $funcArg = "A1:A$maxRow";
  19. if ($arg !== null) {
  20. $sheet->getCell("A$maxRow")->setValue($arg);
  21. }
  22. }
  23. $sheet->getCell('B1')->setValue("=SUMSQ($funcArg)");
  24. $result = $sheet->getCell('B1')->getCalculatedValue();
  25. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  26. }
  27. public function providerSUMSQ(): array
  28. {
  29. return require 'tests/data/Calculation/MathTrig/SUMSQ.php';
  30. }
  31. }