LinEstTest.php 941 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  4. use PHPUnit\Framework\TestCase;
  5. class LinEstTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider providerLINEST
  9. *
  10. * @param mixed $xValues
  11. * @param mixed $yValues
  12. * @param mixed $const
  13. * @param mixed $stats
  14. */
  15. public function testLINEST(array $expectedResult, $yValues, $xValues, $const, $stats): void
  16. {
  17. $result = Statistical::LINEST($yValues, $xValues, $const, $stats);
  18. self::assertIsArray($result);
  19. $elements = count($expectedResult);
  20. for ($element = 0; $element < $elements; ++$element) {
  21. self::assertEqualsWithDelta($expectedResult[$element], $result[$element], 1E-12);
  22. }
  23. }
  24. public function providerLINEST(): array
  25. {
  26. return require 'tests/data/Calculation/Statistical/LINEST.php';
  27. }
  28. }