You are here

public function PaymentUnitTest::testGetLineItems in Payment 8.2

Tests setLineItems() and getLineItems().

File

tests/src/Kernel/PaymentUnitTest.php, line 119

Class

PaymentUnitTest
\Drupal\payment\Entity\Payment unit test.

Namespace

Drupal\Tests\payment\Kernel

Code

public function testGetLineItems() {
  $line_item_1 = $this->lineItemManager
    ->createInstance('payment_basic');
  $line_item_1
    ->setName($this
    ->randomMachineName());
  $line_item_2 = $this->lineItemManager
    ->createInstance('payment_basic');
  $line_item_2
    ->setName($this
    ->randomMachineName());
  $this
    ->assertEquals(spl_object_hash($this->payment
    ->setLineItems([
    $line_item_1,
    $line_item_2,
  ])), spl_object_hash($this->payment));
  $line_items = $this->payment
    ->getLineItems();
  $this
    ->assertTrue(is_array($line_items));
  $this
    ->assertEqual(spl_object_hash($line_items[$line_item_1
    ->getName()]), spl_object_hash($line_item_1));
  $this
    ->assertEqual(spl_object_hash($line_items[$line_item_2
    ->getName()]), spl_object_hash($line_item_2));
}