function UcAddressesCartCheckoutTestCase::populateCheckoutForm in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 tests/uc_addresses.checkout.test \UcAddressesCartCheckoutTestCase::populateCheckoutForm()
Override of UbercartTestHelper::populateCheckoutForm().
With Ubercart Addresses, address fields on checkout have a bit different name. Example: Instead of "panes[delivery][delivery_first_name]", Ubercart Addresses uses "panes[delivery][address][delivery_first_name]". This is done to fix issues with the zone field.
Parameters
array $edit: The form-values array to which to add required fields.
array $address_panes: (optional) The address panes to populate. Defaults to both billing and delivery pane.
Overrides UbercartTestHelper::populateCheckoutForm
3 calls to UcAddressesCartCheckoutTestCase::populateCheckoutForm()
- UcAddressesCartCheckoutTestCase::checkout in tests/
uc_addresses.checkout.test - Override of UbercartTestHelper::checkout().
- UcAddressesCartCheckoutTestCase::testAnonymousCheckoutWithoutMailAddress in tests/
uc_addresses.checkout.test - Tests if a customer can checkout when not providing a mail address.
- UcAddressesCartCheckoutTestCase::testCheckoutSameAddress in tests/
uc_addresses.checkout.test - Test a checkout with the "Use the same address" setting.
File
- tests/
uc_addresses.checkout.test, line 115 - Test cases for checkout.
Class
- UcAddressesCartCheckoutTestCase
- Test cases for checkout.
Code
function populateCheckoutForm($edit = array(), $address_panes = array(
'billing',
'delivery',
)) {
foreach ($address_panes as $pane) {
$prefix = 'panes[' . $pane . '][address][' . $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;
}