public function LineItemCollectionTest::testSetLineItems in Payment 8.2
@covers ::setLineItems @covers ::getLineItem @covers ::getLineItems
File
- tests/
src/ Unit/ LineItemCollectionTest.php, line 123
Class
- LineItemCollectionTest
- @coversDefaultClass \Drupal\payment\LineItemCollection
Namespace
Drupal\Tests\payment\UnitCode
public function testSetLineItems() {
$line_item_name_a = $this
->randomMachineName();
$line_item_a = $this
->createMock(PaymentLineItemInterface::class);
$line_item_a
->expects($this
->atLeastOnce())
->method('getName')
->willReturn($line_item_name_a);
$line_item_name_b = $this
->randomMachineName();
$line_item_b = $this
->createMock(PaymentLineItemInterface::class);
$line_item_b
->expects($this
->atLeastOnce())
->method('getName')
->willReturn($line_item_name_b);
$line_items = [
$line_item_name_a => $line_item_a,
$line_item_name_b => $line_item_b,
];
$this
->assertSame($this->sut, $this->sut
->setLineItems($line_items));
$this
->assertSame($line_item_a, $this->sut
->getLineItem($line_item_name_a));
$this
->assertSame($line_item_b, $this->sut
->getLineItem($line_item_name_b));
$expected = [
$line_item_name_a => $line_item_a,
$line_item_name_b => $line_item_b,
];
$this
->assertSame($expected, $this->sut
->getLineItems());
}