You are here

public function UbercartOrderTestCase::testOrderEntity in Ubercart 7.3

Tests order CRUD operations.

File

uc_order/tests/uc_order.test, line 43
Tests for Ubercart orders.

Class

UbercartOrderTestCase
Tests for Ubercart orders.

Code

public function testOrderEntity() {
  $order = entity_create('uc_order', array());
  $this
    ->assertEqual($order->uid, 0, 'New order is anonymous.');
  $this
    ->assertEqual($order->order_status, 'in_checkout', 'New order is in checkout.');
  $name = $this
    ->randomName();
  $order = entity_create('uc_order', array(
    'uid' => $this->customer->uid,
    'order_status' => 'completed',
    'billing_first_name' => $name,
    'billing_last_name' => $name,
  ));
  $this
    ->assertEqual($order->uid, $this->customer->uid, 'New order has correct uid.');
  $this
    ->assertEqual($order->order_status, 'completed', 'New order is marked completed.');
  $this
    ->assertEqual($order->billing_first_name, $name, 'New order has correct name.');
  $this
    ->assertEqual($order->billing_last_name, $name, 'New order has correct name.');

  // Test deletion.
  entity_delete('uc_order', $order->order_id);
  $deleted_order = entity_load('uc_order', array(
    $order->order_id,
  ), array(), TRUE);
  $this
    ->assertFalse($deleted_order, 'Order was successfully deleted');
}