SumX2PY2Test.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  4. class SumX2PY2Test extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerSUMX2PY2
  8. *
  9. * @param mixed $expectedResult
  10. */
  11. public function testSUMX2PY2($expectedResult, array $matrixData1, array $matrixData2): void
  12. {
  13. $this->mightHaveException($expectedResult);
  14. $sheet = $this->getSheet();
  15. $maxRow = 0;
  16. $funcArg1 = '';
  17. foreach (Functions::flattenArray($matrixData1) as $arg) {
  18. ++$maxRow;
  19. $funcArg1 = "A1:A$maxRow";
  20. $this->setCell("A$maxRow", $arg);
  21. }
  22. $maxRow = 0;
  23. $funcArg2 = '';
  24. foreach (Functions::flattenArray($matrixData2) as $arg) {
  25. ++$maxRow;
  26. $funcArg2 = "C1:C$maxRow";
  27. $this->setCell("C$maxRow", $arg);
  28. }
  29. $sheet->getCell('B1')->setValue("=SUMX2PY2($funcArg1, $funcArg2)");
  30. $result = $sheet->getCell('B1')->getCalculatedValue();
  31. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  32. }
  33. public function providerSUMX2PY2(): array
  34. {
  35. return require 'tests/data/Calculation/MathTrig/SUMX2PY2.php';
  36. }
  37. }