You are here

public function UCXFTestCase::populateCheckoutForm in Extra Fields Checkout Pane 6.2

Same name and namespace in other branches
  1. 7 uc_extra_fields_pane.test \UCXFTestCase::populateCheckoutForm()

Populates the checkout form.

Parameters

$edit: The form-values array to which to add required fields.

1 call to UCXFTestCase::populateCheckoutForm()
UCXFCheckoutTestCase::testSanitizing in ./uc_extra_fields_pane.test
Test if field values are properly sanitized.

File

./uc_extra_fields_pane.test, line 475
Automated tests for Extra Fields Pane

Class

UCXFTestCase
Base class for all Extra Fields Pane test cases.

Code

public 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_result(db_query('SELECT zone_id FROM {uc_zones} WHERE zone_country_id = %s ORDER BY rand() LIMIT 1', $country));
    $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;
}