You are here

public function LineItemCollectionTest::testGetAmount in Payment 8.2

@covers ::getAmount

File

tests/src/Unit/LineItemCollectionTest.php, line 192

Class

LineItemCollectionTest
@coversDefaultClass \Drupal\payment\LineItemCollection

Namespace

Drupal\Tests\payment\Unit

Code

public function testGetAmount() {
  $line_item_amount_a = mt_rand();
  $line_item_amount_b = mt_rand();

  /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface|\PHPUnit\Framework\MockObject\MockObject $line_item_a */

  /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface|\PHPUnit\Framework\MockObject\MockObject $line_item_b */
  list($line_item_a, $line_item_b) = array_values($this->lineItems);
  $line_item_a
    ->expects($this
    ->atLeastOnce())
    ->method('getTotalAmount')
    ->willReturn($line_item_amount_a);
  $line_item_b
    ->expects($this
    ->atLeastOnce())
    ->method('getTotalAmount')
    ->willReturn($line_item_amount_b);
  $this
    ->assertSame(bcadd($line_item_amount_a, $line_item_amount_b, 6), $this->sut
    ->getAmount());
}