BetaDistTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  5. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  6. use PHPUnit\Framework\TestCase;
  7. class BetaDistTest extends TestCase
  8. {
  9. protected function setUp(): void
  10. {
  11. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerBETADIST
  15. *
  16. * @param mixed $expectedResult
  17. */
  18. public function testBETADIST($expectedResult, ...$args): void
  19. {
  20. $result = Statistical::BETADIST(...$args);
  21. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  22. }
  23. public function providerBETADIST(): array
  24. {
  25. return require 'tests/data/Calculation/Statistical/BETADIST.php';
  26. }
  27. /**
  28. * @dataProvider providerBetaDistArray
  29. */
  30. public function testBetaDistArray(array $expectedResult, string $argument1, string $argument2, string $argument3): void
  31. {
  32. $calculation = Calculation::getInstance();
  33. $formula = "=BETADIST({$argument1}, {$argument2}, {$argument3})";
  34. $result = $calculation->_calculateFormulaValue($formula);
  35. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  36. }
  37. public function providerBetaDistArray(): array
  38. {
  39. return [
  40. 'row/column vectors' => [
  41. [[0.25846539810299873, 0.05696312425682317], [0.3698138247709718, 0.10449584381010533]],
  42. '0.25',
  43. '{5, 7.5}',
  44. '{10; 12}',
  45. ],
  46. ];
  47. }
  48. }