TrendTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  5. use PHPUnit\Framework\TestCase;
  6. class TrendTest extends TestCase
  7. {
  8. protected function setUp(): void
  9. {
  10. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  11. }
  12. /**
  13. * @dataProvider providerGROWTH
  14. *
  15. * @param mixed $expectedResult
  16. */
  17. public function testTREND($expectedResult, array $yValues, array $xValues, ?array $newValues = null, ?bool $const = null): void
  18. {
  19. if ($newValues === null) {
  20. $result = Statistical::TREND($yValues, $xValues);
  21. } elseif ($const === null) {
  22. $result = Statistical::TREND($yValues, $xValues, $newValues);
  23. } else {
  24. $result = Statistical::TREND($yValues, $xValues, $newValues, $const);
  25. }
  26. self::assertEqualsWithDelta($expectedResult, $result[0], 1E-12);
  27. }
  28. public function providerGROWTH(): array
  29. {
  30. return require 'tests/data/Calculation/Statistical/TREND.php';
  31. }
  32. }