You are here

function CurrencyTest::testRenderWithExistingCurrency in Currency 8.3

@covers ::render

File

tests/src/Unit/Plugin/views/field/CurrencyTest.php, line 123

Class

CurrencyTest
@coversDefaultClass \Drupal\currency\Plugin\views\field\Currency

Namespace

Drupal\Tests\currency\Unit\Plugin\views\field

Code

function testRenderWithExistingCurrency() {
  $currency_code = $this
    ->randomMachineName();
  $currency_method_return_value = $this
    ->randomMachineName();
  $field_alias = $this
    ->randomMachineName();
  $this->sut->field_alias = $field_alias;
  $result_row = new ResultRow([
    $field_alias => $currency_code,
  ]);
  $currency = $this
    ->createMock(CurrencyInterface::class);
  $currency
    ->expects($this
    ->atLeastOnce())
    ->method($this->pluginConfiguration['currency_method'])
    ->willReturn($currency_method_return_value);
  $this->currencyStorage
    ->expects($this
    ->atLeastOnce())
    ->method('load')
    ->with($currency_code)
    ->willReturn($currency);
  $this
    ->assertSame($currency_method_return_value, $this->sut
    ->render($result_row));
}