You are here

protected function UbercartCreditCardTestCase::createOrder in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 payment/uc_credit/uc_credit.test \UbercartCreditCardTestCase::createOrder()

Helper function. Creates a new order.

1 call to UbercartCreditCardTestCase::createOrder()
UbercartCreditCardTestCase::testExpiryDate in payment/uc_credit/tests/uc_credit.test
Tests that expiry date validation functions correctly.

File

payment/uc_credit/tests/uc_credit.test, line 153
Credit card payment method tests.

Class

UbercartCreditCardTestCase
Tests credit card payments with the test gateway.

Code

protected 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;
}