protected function UbercartTestHelper::populateCheckoutForm in Ubercart 7.3
Helper function to fill-in required fields on the checkout page.
Parameters
$edit: The form-values array to which to add required fields.
2 calls to UbercartTestHelper::populateCheckoutForm()
- UbercartQuoteTestCase::testQuote in shipping/
uc_quote/ tests/ uc_quote.test - Tests basic flatrate shipping quote functionality.
- UbercartTestHelper::checkout in uc_store/
tests/ uc_store.test - Executes the checkout process.
File
- uc_store/
tests/ uc_store.test, line 113 - Test functionality provided by uc_store.
Class
- UbercartTestHelper
- Defines a base helper class for Ubercart tests.
Code
protected function populateCheckoutForm($edit = array()) {
foreach (array(
'billing',
'delivery',
) as $pane) {
$prefix = 'panes[' . $pane . '][' . $pane;
$key = $prefix . '_country]';
$country = empty($edit[$key]) ? variable_get('uc_store_country', 840) : $edit[$key];
$zone_id = db_query_range('SELECT zone_id FROM {uc_zones} WHERE zone_country_id = :country ORDER BY rand()', 0, 1, array(
'country' => $country,
))
->fetchField();
$edit += array(
$prefix . '_first_name]' => $this
->randomName(10),
$prefix . '_last_name]' => $this
->randomName(10),
$prefix . '_street1]' => $this
->randomName(10),
$prefix . '_city]' => $this
->randomName(10),
$prefix . '_zone]' => $zone_id,
$prefix . '_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';
}
return $edit;
}