You are here

function UCRestrictQtyFunctionalTest::drupalCreateOrder in Ubercart Restrict Qty 6.2

Same name and namespace in other branches
  1. 7 tests/uc_restrict_qty.test \UCRestrictQtyFunctionalTest::drupalCreateOrder()
1 call to UCRestrictQtyFunctionalTest::drupalCreateOrder()
UCRestrictQtyFunctionalTest::testProductLimit in tests/uc_restrict_qty.test

File

tests/uc_restrict_qty.test, line 53
UC Restrict Qty auto-tests.

Class

UCRestrictQtyFunctionalTest
@file UC Restrict Qty auto-tests.

Code

function drupalCreateOrder($products = array(), $user = NULL) {
  if (!isset($user)) {
    $user = $this
      ->drupalCreateUser();
  }
  $order = uc_order_new($user->uid);
  if (!empty($products)) {
    foreach ($products as $product) {
      $product_data->order_product_id = 0;
      $product_data->nid = $product->nid;
      $product_data->qty = 1;
      $product_data->title = $product->title;
      $product_data->model = $product->model;
      $product_data->cost = $product->cost;
      $product_data->price = $product->sell_price;
      $order->products[] = $product_data;
    }
  }
  $order->delivery_first_name = $this
    ->randomName();
  $order->delivery_last_name = $this
    ->randomName();
  $order->delivery_phone = $this
    ->randomName();
  $order->delivery_company = $this
    ->randomName();
  $order->delivery_street1 = $this
    ->randomName();
  $order->delivery_street2 = $this
    ->randomName();
  $order->delivery_city = $this
    ->randomName();
  $order->delivery_zone = $this
    ->randomName();
  $order->delivery_postal_code = $this
    ->randomName();
  $order->delivery_country = $this
    ->randomName();
  $order->billing_first_name = $this
    ->randomName();
  $order->billing_last_name = $this
    ->randomName();
  $order->billing_phone = $this
    ->randomName();
  $order->billing_company = $this
    ->randomName();
  $order->billing_street1 = $this
    ->randomName();
  $order->billing_street2 = $this
    ->randomName();
  $order->billing_city = $this
    ->randomName();
  $order->billing_zone = $this
    ->randomName();
  $order->billing_postal_code = $this
    ->randomName();
  $order->billing_country = $this
    ->randomName();
  $order->payment_method = $this
    ->randomName();
  $order->manufacturer = $this
    ->randomName();
  $order->weight = rand();
  $order->data = array();
  uc_order_save($order);
  return $order;
}