TinvTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  5. use PHPUnit\Framework\TestCase;
  6. class TinvTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerTINV
  10. *
  11. * @param mixed $expectedResult
  12. * @param mixed $probability
  13. * @param mixed $degrees
  14. */
  15. public function testTINV($expectedResult, $probability, $degrees): void
  16. {
  17. $result = Statistical::TINV($probability, $degrees);
  18. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  19. }
  20. public function providerTINV(): array
  21. {
  22. return require 'tests/data/Calculation/Statistical/TINV.php';
  23. }
  24. /**
  25. * @dataProvider providerTInvArray
  26. */
  27. public function testTInvArray(array $expectedResult, string $values, string $degrees): void
  28. {
  29. $calculation = Calculation::getInstance();
  30. $formula = "=TINV({$values}, {$degrees})";
  31. $result = $calculation->_calculateFormulaValue($formula);
  32. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  33. }
  34. public function providerTInvArray(): array
  35. {
  36. return [
  37. 'row vector' => [
  38. [
  39. [0.29001075058679815, 0.5023133547575189, 0.4713169827948964],
  40. ],
  41. '0.65',
  42. '{1.5, 3.5, 8}',
  43. ],
  44. ];
  45. }
  46. }