You are here

public function UCXFTestCase::UbercartCheckout in Extra Fields Checkout Pane 7

Similar to UbercartTestHelper::checkout().

Return value

object An Ubercart order object, if checkout succeeded. False otherwise.

1 call to UCXFTestCase::UbercartCheckout()
UCXFTestCase::checkout in ./uc_extra_fields_pane.test
Overrides UbercartTestHelper::checkout().

File

./uc_extra_fields_pane.test, line 420
Automated tests for Extra Fields Pane

Class

UCXFTestCase
Base class for all Extra Fields Pane test cases.

Code

public function UbercartCheckout($edit = array()) {
  $this
    ->drupalPost('cart', array(), 'Checkout');
  $edit = $this
    ->populateCheckoutForm($edit);

  // Submit the checkout page.
  $this
    ->drupalPost('cart/checkout', $edit, t('Review order'));
  $this
    ->assertRaw(t('Your order is almost complete.'));

  // Complete the review page.
  $this
    ->drupalPost(NULL, array(), t('Submit order'));
  $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", array(
    ':name' => $edit['panes[delivery][address][delivery_first_name]'],
  ))
    ->fetchField();
  if ($order_id) {
    $this
      ->pass(t('Order %order_id has been created', array(
      '%order_id' => $order_id,
    )));
    $order = uc_order_load($order_id);
  }
  else {
    $this
      ->fail(t('An order was created.'));
    $order = FALSE;
  }
  return $order;
}