You are here

protected function UbercartOrderTestCase::ucCreateOrder in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_order/tests/uc_order.test \UbercartOrderTestCase::ucCreateOrder()
1 call to UbercartOrderTestCase::ucCreateOrder()
UbercartOrderTestCase::testOrderEditing in uc_order/uc_order.test

File

uc_order/uc_order.test, line 65
Tests for Ubercart orders.

Class

UbercartOrderTestCase

Code

protected function ucCreateOrder($customer) {
  $order = uc_order_new($customer->uid);
  uc_order_comment_save($order->order_id, 0, t('Order created programmatically.'), 'admin');
  $order_exists = db_result(db_query("SELECT 1 FROM {uc_orders} WHERE order_id = %d", $order->order_id));
  $this
    ->assertTrue($order_exists, t('Found order ID @order_id', array(
    '@order_id' => $order->order_id,
  )));
  $zone_id = db_result(db_query('SELECT zone_id FROM {uc_zones} WHERE zone_country_id = %s ORDER BY rand() LIMIT 1', variable_get('uc_store_country', 840)));
  $order->delivery_first_name = $this
    ->randomName(12);
  $order->delivery_last_name = $this
    ->randomName(12);
  $order->delivery_street1 = $this
    ->randomName(12);
  $order->delivery_street2 = $this
    ->randomName(12);
  $order->delivery_city = $this
    ->randomName(12);
  $order->delivery_zone = $zone_id;
  $order->delivery_postal_code = mt_rand(10000, 99999);
  $order->delivery_country = 840;
  $order->billing_first_name = $this
    ->randomName(12);
  $order->billing_last_name = $this
    ->randomName(12);
  $order->billing_street1 = $this
    ->randomName(12);
  $order->billing_street2 = $this
    ->randomName(12);
  $order->billing_city = $this
    ->randomName(12);
  $order->billing_zone = $zone_id;
  $order->billing_postal_code = mt_rand(10000, 99999);
  $order->billing_country = 840;
  uc_order_save($order);
  $db_order = db_fetch_object(db_query("SELECT * FROM {uc_orders} WHERE order_id = %d", $order->order_id));
  $this
    ->assertEqual($order->delivery_first_name, $db_order->delivery_first_name);
  $this
    ->assertEqual($order->delivery_last_name, $db_order->delivery_last_name);
  $this
    ->assertEqual($order->delivery_street1, $db_order->delivery_street1);
  $this
    ->assertEqual($order->delivery_street2, $db_order->delivery_street2);
  $this
    ->assertEqual($order->delivery_city, $db_order->delivery_city);
  $this
    ->assertEqual($order->delivery_zone, $db_order->delivery_zone);
  $this
    ->assertEqual($order->delivery_postal_code, $db_order->delivery_postal_code);
  $this
    ->assertEqual($order->delivery_country, $db_order->delivery_country);
  $this
    ->assertEqual($order->billing_first_name, $db_order->billing_first_name);
  $this
    ->assertEqual($order->billing_last_name, $db_order->billing_last_name);
  $this
    ->assertEqual($order->billing_street1, $db_order->billing_street1);
  $this
    ->assertEqual($order->billing_street2, $db_order->billing_street2);
  $this
    ->assertEqual($order->billing_city, $db_order->billing_city);
  $this
    ->assertEqual($order->billing_zone, $db_order->billing_zone);
  $this
    ->assertEqual($order->billing_postal_code, $db_order->billing_postal_code);
  $this
    ->assertEqual($order->billing_country, $db_order->billing_country);
  return $order;
}