function AmountTest::testRender in Currency 8.3
@covers ::render
@dataProvider providerTestRender
@depends testGetAmount @depends testGetCurrencyWithoutLoadableCurrencies @depends testGetCurrencyWithFallbackCurrency @depends testGetCurrencyWithFixedCurrency @depends testGetCurrencyWithCurrencyCodeField
File
- tests/
src/ Unit/ Plugin/ views/ field/ AmountTest.php, line 363
Class
- AmountTest
- @coversDefaultClass \Drupal\currency\Plugin\views\field\Amount
Namespace
Drupal\Tests\currency\Unit\Plugin\views\fieldCode
function testRender($round) {
$amount = mt_rand();
$formatted_amount = $this
->randomMachineName();
$field_alias = $this
->randomMachineName();
$currency_code = $this
->randomMachineName();
$currency = $this
->createMock(CurrencyInterface::class);
$currency
->expects($this
->atLeastOnce())
->method('formatAmount')
->with($amount, $round)
->willReturn($formatted_amount);
$this->currencyStorage
->expects($this
->atLeastOnce())
->method('load')
->with($currency_code)
->willReturn($currency);
$result_row = new ResultRow([
$field_alias => $amount,
]);
$configuration = [];
$plugin_id = $this
->randomMachineName();
$this->pluginDefinition['currency_code'] = $currency_code;
$options = [
'currency_round' => $round,
];
$this->sut = new Amount($configuration, $plugin_id, $this->pluginDefinition, $this->stringTranslation, $this->moduleHandler, $this->renderer, $this->currencyStorage);
$this->sut
->init($this->viewsViewExecutable, $this->viewsDisplayHandler, $options);
$this->sut->field_alias = $field_alias;
$this
->assertSame($formatted_amount, $this->sut
->render($result_row));
}