You are here

public function UbercartCartCheckoutTestCase::testCheckoutNewUsername in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_cart/uc_cart.test \UbercartCartCheckoutTestCase::testCheckoutNewUsername()

Tests generating a new account at checkout.

File

uc_cart/tests/uc_cart.test, line 318
Shopping cart and checkout tests.

Class

UbercartCartCheckoutTestCase
Tests the cart and checkout functionality.

Code

public function testCheckoutNewUsername() {

  // Configure the checkout for this test.
  $this
    ->drupalLogin($this->adminUser);
  $settings = array(
    // Allow customer to specify username.
    'uc_cart_new_account_name' => TRUE,
    // Disable address panes.
    'uc_pane_delivery_enabled' => FALSE,
    'uc_pane_billing_enabled' => FALSE,
  );
  $this
    ->drupalPost('admin/store/settings/checkout/panes', $settings, t('Save configuration'));
  $this
    ->drupalLogout();

  // Test with an account that already exists.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $edit = array(
    'panes[customer][primary_email]' => $this
      ->randomName(8) . '@example.com',
    'panes[customer][new_account][name]' => $this->adminUser->name,
  );
  $this
    ->drupalPost('cart/checkout', $edit, 'Review order');
  $this
    ->assertText('The username ' . $this->adminUser->name . ' is already taken.');

  // Let the account be automatically created instead.
  $edit = array(
    'panes[customer][primary_email]' => $this
      ->randomName(8) . '@example.com',
    'panes[customer][new_account][name]' => '',
  );
  $this
    ->drupalPost('cart/checkout', $edit, 'Review order');
  $this
    ->drupalPost(NULL, array(), 'Submit order');
  $this
    ->assertText('Your order is complete!');
  $this
    ->assertText('A new account has been created');
}