GeStepTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Engineering;
  5. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  6. use PHPUnit\Framework\TestCase;
  7. class GeStepTest extends TestCase
  8. {
  9. protected function setUp(): void
  10. {
  11. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerGESTEP
  15. *
  16. * @param mixed $a
  17. * @param mixed $b
  18. * @param mixed $expectedResult
  19. */
  20. public function testGESTEP($expectedResult, $a, $b): void
  21. {
  22. $result = Engineering::GESTEP($a, $b);
  23. self::assertEquals($expectedResult, $result);
  24. }
  25. public function providerGESTEP(): array
  26. {
  27. return require 'tests/data/Calculation/Engineering/GESTEP.php';
  28. }
  29. /**
  30. * @dataProvider providerGeStepArray
  31. */
  32. public function testGeStepArray(array $expectedResult, string $a, string $b): void
  33. {
  34. $calculation = Calculation::getInstance();
  35. $formula = "=GESTEP({$a}, {$b})";
  36. $result = $calculation->_calculateFormulaValue($formula);
  37. self::assertEquals($expectedResult, $result);
  38. }
  39. public function providerGeStepArray(): array
  40. {
  41. return [
  42. 'row/column vector' => [
  43. [
  44. [1, 1, 1, 1, 1],
  45. [0, 1, 1, 1, 1],
  46. [0, 1, 1, 1, 0],
  47. [0, 1, 0, 1, 0],
  48. [0, 1, 0, 0, 0],
  49. ],
  50. '{-1.2, 2.5, 0.0, 0.25, -0.5}',
  51. '{-1.2; -0.5; 0.0; 0.25; 2.5}',
  52. ],
  53. ];
  54. }
  55. }