protected function UbercartBrowserTestBase::populateCheckoutForm in Ubercart 8.4
Helper function to fill-in required fields on the checkout page.
Parameters
array $edit: The form-values array to which to add required fields.
Return value
array The values array ready to pass to the checkout page.
8 calls to UbercartBrowserTestBase::populateCheckoutForm()
- CartCheckoutTest::testCartOrderTimeout in uc_cart/
tests/ src/ Functional/ CartCheckoutTest.php - Tests that cart orders are marked abandoned after a timeout.
- CartRulesEventsTest::testRulesEvents in uc_cart/
tests/ src/ Functional/ CartRulesEventsTest.php - Tests the three events provided by uc_cart.
- CreditCardTest::testCheckout in payment/
uc_credit/ tests/ src/ Functional/ CreditCardTest.php - Tests that an order can be placed using the test gateway.
- InclusiveTaxTest::testProductKitAttributes in uc_tax/
tests/ src/ Functional/ InclusiveTaxTest.php - Test inclusive taxes with product kit attributes.
- OrderCommentsTest::testUserCheckoutAddComment in uc_order/
tests/ src/ Functional/ OrderCommentsTest.php - Tests adding admin comments on administrator's order view page.
1 method overrides UbercartBrowserTestBase::populateCheckoutForm()
- RoleTest::populateCheckoutForm in uc_role/
tests/ src/ Functional/ RoleTest.php - Helper function to fill-in required fields on the checkout page.
File
- uc_store/
tests/ src/ Functional/ UbercartBrowserTestBase.php, line 132
Class
- UbercartBrowserTestBase
- Base class for Ubercart PHPUnit browser tests.
Namespace
Drupal\Tests\uc_store\FunctionalCode
protected function populateCheckoutForm(array $edit = []) {
foreach ([
'billing',
'delivery',
] as $pane) {
$prefix = 'panes[' . $pane . ']';
$key = $prefix . '[country]';
$country_id = isset($edit[$key]) ? $edit[$key] : \Drupal::config('uc_store.settings')
->get('address.country');
$country = \Drupal::service('country_manager')
->getCountry($country_id);
$edit += [
$prefix . '[first_name]' => $this
->randomMachineName(10),
$prefix . '[last_name]' => $this
->randomMachineName(10),
$prefix . '[street1]' => $this
->randomMachineName(10),
$prefix . '[city]' => $this
->randomMachineName(10),
$prefix . '[postal_code]' => (string) mt_rand(10000, 99999),
$prefix . '[country]' => $country_id,
];
// Don't try to set the zone unless the store country has zones!
if (!empty($country
->getZones())) {
$edit += [
$prefix . '[zone]' => array_rand($country
->getZones()),
];
}
}
// 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
->randomMachineName(8) . '@example.com';
}
return $edit;
}