You are here

protected function PriceSplitterTest::buildOrderItems in Commerce Core 8.2

Builds the order items for the given unit prices.

Parameters

\Drupal\commerce_price\Price[] $unit_prices: The unit prices.

string $quantity: The quantity. Same for all items.

Return value

\Drupal\commerce_order\Entity\OrderItemInterface[] The order items.

1 call to PriceSplitterTest::buildOrderItems()
PriceSplitterTest::testSplit in modules/order/tests/src/Kernel/PriceSplitterTest.php
@covers ::split

File

modules/order/tests/src/Kernel/PriceSplitterTest.php, line 132

Class

PriceSplitterTest
Tests the price splitter.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

protected function buildOrderItems(array $unit_prices, $quantity = '1') {
  $order_items = [];
  foreach ($unit_prices as $unit_price) {
    $order_item = OrderItem::create([
      'type' => 'test',
      'unit_price' => $unit_price,
      'quantity' => $quantity,
    ]);
    $order_item
      ->save();
    $order_items[] = $order_item;
  }
  return $order_items;
}