UsDollarTest.php 768 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Dollar;
  4. use PHPUnit\Framework\TestCase;
  5. class UsDollarTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider providerUSDOLLAR
  9. *
  10. * @param mixed $expectedResult
  11. */
  12. public function testUSDOLLAR($expectedResult, float $amount, ?int $precision = null): void
  13. {
  14. if ($precision === null) {
  15. $result = Dollar::format($amount);
  16. } else {
  17. $result = Dollar::format($amount, $precision);
  18. }
  19. self::assertSame($expectedResult, $result);
  20. }
  21. public function providerUSDOLLAR(): array
  22. {
  23. return require 'tests/data/Calculation/Financial/USDOLLAR.php';
  24. }
  25. }