public function UcAddressesCartCheckoutTestCase::testCheckoutSameAddress in Ubercart Addresses 7
Test a checkout with the "Use the same address" setting.
Test specifically if this works when there are address fields that appear in one of the address panes only.
File
- tests/
uc_addresses.checkout.test, line 572 - Test cases for checkout.
Class
- UcAddressesCartCheckoutTestCase
- Test cases for checkout.
Code
public function testCheckoutSameAddress() {
// Enable the uc_addresses_test module.
module_enable(array(
'uc_addresses_test',
));
drupal_get_schema(NULL, TRUE);
// Enable "Use the same address" setting.
variable_set('uc_cart_default_same_address', TRUE);
// Post product to cart.
$this
->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
$this
->drupalPost('cart', array(), 'Checkout');
// Checkout and submit order.
$edit = $this
->populateCheckoutForm(array(), array(
'delivery',
));
$this
->drupalPost('cart/checkout', $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, we check against billing first pane
// because the billing address should be the same as the delivery address.
$conditions = array(
'billing_first_name' => $edit['panes[delivery][address][delivery_first_name]'],
);
$order = $this
->checkExistingOrder($conditions);
// Now, reverse the delivery and billing panes and check again.
variable_set('uc_pane_billing_weight', 1);
variable_set('uc_pane_delivery_weight', 2);
// Post product to cart.
$this
->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
$this
->drupalPost('cart', array(), 'Checkout');
// Checkout and submit order.
$edit = $this
->populateCheckoutForm(array(), array(
'billing',
));
$this
->drupalPost('cart/checkout', $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, this time we check against delivery first name.
$conditions = array(
'delivery_first_name' => $edit['panes[billing][address][billing_first_name]'],
);
$order = $this
->checkExistingOrder($conditions);
}