PmtTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Financial;
  4. use PHPUnit\Framework\TestCase;
  5. class PmtTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider providerPMT
  9. *
  10. * @param mixed $expectedResult
  11. */
  12. public function testPMT($expectedResult, array $args): void
  13. {
  14. $interestRate = array_shift($args);
  15. $numberOfPeriods = array_shift($args);
  16. $presentValue = array_shift($args);
  17. if (count($args) === 0) {
  18. $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue);
  19. } elseif (count($args) === 1) {
  20. $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0]);
  21. } else {
  22. $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0], $args[1]);
  23. }
  24. self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
  25. }
  26. public function providerPMT(): array
  27. {
  28. return require 'tests/data/Calculation/Financial/PMT.php';
  29. }
  30. }