GammaLnTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 GammaLnTest extends TestCase
  8. {
  9. protected function setUp(): void
  10. {
  11. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerGAMMALN
  15. *
  16. * @param mixed $expectedResult
  17. * @param mixed $value
  18. */
  19. public function testGAMMALN($expectedResult, $value): void
  20. {
  21. $result = Statistical::GAMMALN($value);
  22. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  23. }
  24. public function providerGAMMALN(): array
  25. {
  26. return require 'tests/data/Calculation/Statistical/GAMMALN.php';
  27. }
  28. /**
  29. * @dataProvider providerGammaLnArray
  30. */
  31. public function testGammaLnArray(array $expectedResult, string $values): void
  32. {
  33. $calculation = Calculation::getInstance();
  34. $formula = "=GAMMALN({$values})";
  35. $result = $calculation->_calculateFormulaValue($formula);
  36. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  37. }
  38. public function providerGammaLnArray(): array
  39. {
  40. return [
  41. 'matrix' => [
  42. [['#NUM!', 1.5240638224308496], [0.20328095143131059, 2.8813232759012433]],
  43. '{-1.5, 0.2; 0.75, 4.8}',
  44. ],
  45. ];
  46. }
  47. }