You are here

function UcAddressesCartCheckoutTestCase::testAnonymousCheckoutWithoutMailAddress in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 tests/uc_addresses.checkout.test \UcAddressesCartCheckoutTestCase::testAnonymousCheckoutWithoutMailAddress()

Tests if a customer can checkout when not providing a mail address.

File

tests/uc_addresses.checkout.test, line 400
Test cases for checkout.

Class

UcAddressesCartCheckoutTestCase
Test cases for checkout.

Code

function testAnonymousCheckoutWithoutMailAddress() {

  // Disable the Customer information pane.
  variable_set('uc_pane_customer_enabled', FALSE);

  // Place item in cart.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));

  // Continue to checkout.
  $this
    ->drupalPost('cart', array(), 'Checkout');

  // Populate checkout form, but omit filling mail address.
  $edit = $this
    ->populateCheckoutForm();
  unset($edit['panes[customer][primary_email]']);

  // And checkout.
  $this
    ->drupalPost(NULL, $edit, t('Review order'));
  $this
    ->assertRaw(t('Your order is almost complete.'));
  $this
    ->drupalPost(NULL, array(), t('Submit order'));

  // Check if an order has been created.
  $order_id = db_result(db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = '%s'", $edit['panes[delivery][delivery][delivery_first_name]']));
  if ($order_id) {
    $this
      ->pass(t('Order %order_id has been created', array(
      '%order_id' => $order_id,
    )));
  }
  else {
    $this
      ->fail(t('An order was created.'));
  }
}