You are here

public function LineItemCollectionTest::testGetLineItemsByType in Payment 8.2

@covers ::getLineItemsByType

File

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

Class

LineItemCollectionTest
@coversDefaultClass \Drupal\payment\LineItemCollection

Namespace

Drupal\Tests\payment\Unit

Code

public function testGetLineItemsByType() {
  $line_item_type = $this
    ->randomMachineName();

  /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface|\PHPUnit\Framework\MockObject\MockObject $line_item_a */
  $line_item_a = reset($this->lineItems);
  $line_item_name_a = key($this->lineItems);
  $line_item_a
    ->expects($this
    ->atLeastOnce())
    ->method('getPluginId')
    ->willReturn($line_item_type);
  $line_item_b = end($this->lineItems);
  $line_item_b
    ->expects($this
    ->atLeastOnce())
    ->method('getPluginId')
    ->willReturn($this
    ->randomMachineName());
  $expected = [
    $line_item_name_a => $line_item_a,
  ];
  $this
    ->assertSame($expected, $this->sut
    ->getLineItemsByType($line_item_type));
}