ExponentialBestFitTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Shared\Trend;
  3. use PhpOffice\PhpSpreadsheet\Shared\Trend\ExponentialBestFit;
  4. use PHPUnit\Framework\TestCase;
  5. class ExponentialBestFitTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider providerExponentialBestFit
  9. *
  10. * @param mixed $expectedSlope
  11. * @param mixed $expectedIntersect
  12. * @param mixed $expectedGoodnessOfFit
  13. * @param mixed $yValues
  14. * @param mixed $xValues
  15. * @param mixed $expectedEquation
  16. */
  17. public function testExponentialBestFit(
  18. $expectedSlope,
  19. $expectedIntersect,
  20. $expectedGoodnessOfFit,
  21. $expectedEquation,
  22. $yValues,
  23. $xValues
  24. ): void {
  25. $bestFit = new ExponentialBestFit($yValues, $xValues);
  26. $slope = $bestFit->getSlope(1);
  27. self::assertEquals($expectedSlope[0], $slope);
  28. $slope = $bestFit->getSlope();
  29. self::assertEquals($expectedSlope[1], $slope);
  30. $intersect = $bestFit->getIntersect(1);
  31. self::assertEquals($expectedIntersect[0], $intersect);
  32. $intersect = $bestFit->getIntersect();
  33. self::assertEquals($expectedIntersect[1], $intersect);
  34. $equation = $bestFit->getEquation(2);
  35. self::assertEquals($expectedEquation, $equation);
  36. self::assertSame($expectedGoodnessOfFit[0], $bestFit->getGoodnessOfFit(6));
  37. self::assertSame($expectedGoodnessOfFit[1], $bestFit->getGoodnessOfFit());
  38. }
  39. public function providerExponentialBestFit(): array
  40. {
  41. return require 'tests/data/Shared/Trend/ExponentialBestFit.php';
  42. }
  43. }