You are here

public function PaymentAmountTest::testRender in Payment 8.2

@covers ::render

File

tests/src/Unit/Plugin/views/field/PaymentAmountTest.php, line 50

Class

PaymentAmountTest
@coversDefaultClass \Drupal\payment\Plugin\views\field\PaymentAmount

Namespace

Drupal\Tests\payment\Unit\Plugin\views\field

Code

public function testRender() {
  $amount = mt_rand();
  $formatted_amount = 'FooBar ' . mt_rand();
  $currency = $this
    ->createMock(CurrencyInterface::class);
  $currency
    ->expects($this
    ->atLeastOnce())
    ->method('formatAmount')
    ->with($amount)
    ->willReturn($formatted_amount);
  $payment = $this
    ->createMock(PaymentInterface::class);
  $payment
    ->expects($this
    ->atLeastOnce())
    ->method('getAmount')
    ->willReturn($amount);
  $payment
    ->expects($this
    ->atLeastOnce())
    ->method('getCurrency')
    ->willReturn($currency);
  $result_row = new ResultRow();
  $result_row->_entity = $payment;
  $this
    ->assertSame($formatted_amount, $this->sut
    ->render($result_row));
}