You are here

function UbercartCartCheckoutTestCase::createOrder in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_cart/tests/uc_cart.test \UbercartCartCheckoutTestCase::createOrder()

Creates a new order.

2 calls to UbercartCartCheckoutTestCase::createOrder()
UbercartCartCheckoutTestCase::testCheckoutComplete in uc_cart/uc_cart.test
UbercartCartCheckoutTestCase::testCheckoutRoleAssignment in uc_cart/uc_cart.test

File

uc_cart/uc_cart.test, line 33
Shopping cart and checkout tests.

Class

UbercartCartCheckoutTestCase
Tests the cart and checkout functionality.

Code

function createOrder($fields = array()) {
  $order = uc_order_new();
  foreach ($fields as $key => $value) {
    $order->{$key} = $value;
  }
  if (empty($order->primary_email)) {
    $order->primary_email = $this
      ->randomString() . '@example.org';
  }
  if (!isset($fields['products'])) {
    $item = clone $this->product;
    $item->qty = 1;
    $item->price = $item->sell_price;
    $item->data = array();
    $order->products = array(
      $item,
    );
  }
  $order->order_total = uc_order_get_total($order, TRUE);
  $order->line_items = uc_order_load_line_items($order, TRUE);
  uc_order_save($order);
  return $order;
}