You are here

function CurrencyTest::testFormatAmount in Currency 8.3

@covers ::formatAmount @covers ::getCurrencyAmountFormatterManager

@depends testGetRoundingStep

@dataProvider providerTestFormatAmount

File

tests/src/Unit/Entity/CurrencyTest.php, line 125

Class

CurrencyTest
@coversDefaultClass \Drupal\currency\Entity\Currency

Namespace

Drupal\Tests\currency\Unit\Entity

Code

function testFormatAmount($expected, $amount, $amount_with_currency_precision_applied) {
  $amount_formatter = $this
    ->createMock(AmountFormatterInterface::class);
  $amount_formatter
    ->expects($this
    ->atLeastOnce())
    ->method('formatAmount')
    ->with($this->sut, $amount_with_currency_precision_applied)
    ->willReturn($expected);
  $this->currencyAmountFormatterManager
    ->expects($this
    ->atLeastOnce())
    ->method('getDefaultPlugin')
    ->willReturn($amount_formatter);
  $this->sut
    ->setCurrencyCode('BLA');
  $this->sut
    ->setSubunits(100);
  $this
    ->assertSame($expected, $this->sut
    ->formatAmount($amount, $amount !== $amount_with_currency_precision_applied));
}