function UbercartTestHelper::checkout in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_store/tests/uc_store.test \UbercartTestHelper::checkout()
Executes the checkout process.
6 calls to UbercartTestHelper::checkout()
- UbercartCartCheckoutTestCase::testCheckout in uc_cart/
uc_cart.test - UbercartCartCheckoutTestCase::testCheckoutLogin in uc_cart/
uc_cart.test - UbercartCreditCardTestCase::brokentestCheckout in payment/
uc_credit/ uc_credit.test - Tests that an order can be placed using the test gateway.
- UbercartRolesTestCase::testRolePurchaseCheckout in uc_roles/
uc_roles.test - UbercartStockTestCase::testStockDecrement in uc_stock/
uc_stock.test
File
- uc_store/
uc_store.test, line 107 - Test functionality provided by uc_store.
Class
- UbercartTestHelper
- Defines a base helper class for Ubercart tests.
Code
function checkout($edit = array()) {
$this
->drupalPost('cart', array(), 'Checkout');
$this
->assertText(t('Enter your billing address and information here.'), t('Viewed cart page: Billing pane has been displayed.'));
// Build the panes.
$zone_id = db_result(db_query('SELECT zone_id FROM {uc_zones} WHERE zone_country_id = %s ORDER BY rand() LIMIT 1', variable_get('uc_store_country', 840)));
$edit += array(
'panes[delivery][delivery_first_name]' => $this
->randomName(10),
'panes[delivery][delivery_last_name]' => $this
->randomName(10),
'panes[delivery][delivery_street1]' => $this
->randomName(10),
'panes[delivery][delivery_city]' => $this
->randomName(10),
'panes[delivery][delivery_zone]' => $zone_id,
'panes[delivery][delivery_postal_code]' => mt_rand(10000, 99999),
'panes[billing][billing_first_name]' => $this
->randomName(10),
'panes[billing][billing_last_name]' => $this
->randomName(10),
'panes[billing][billing_street1]' => $this
->randomName(10),
'panes[billing][billing_city]' => $this
->randomName(10),
'panes[billing][billing_zone]' => $zone_id,
'panes[billing][billing_postal_code]' => mt_rand(10000, 99999),
);
// If the email address has not been set, and the user has not logged in,
// add a primary email address.
if (!isset($edit['panes[customer][primary_email]']) && !$this->loggedInUser) {
$edit['panes[customer][primary_email]'] = $this
->randomName(8) . '@example.com';
}
// 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_result(db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = '%s'", $edit['panes[delivery][delivery_first_name]']));
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('No order was created.'));
$order = FALSE;
}
return $order;
}