protected function StoreCreationTrait::createStore in Commerce Core 8.2
Creates a store for the test.
Parameters
string $name: The store name.
string $mail: The store email.
string $type: The store type.
bool $default: Whether the store should be the default store.
string $country: The store country code.
string $currency: The store currency code.
Return value
\Drupal\commerce_store\Entity\StoreInterface The store.
24 calls to StoreCreationTrait::createStore()
- CartOrderPlacedTest::testCartOrderPlaced in modules/
cart/ tests/ src/ Kernel/ CartOrderPlacedTest.php - Tests that a draft order is no longer a cart once placed.
- CartProviderTest::testGetAnonymousCart in modules/
cart/ tests/ src/ Kernel/ CartProviderTest.php - Tests getting an anonymous user's cart.
- CartProviderTest::testGetAuthenticatedCart in modules/
cart/ tests/ src/ Kernel/ CartProviderTest.php - Tests getting an authenticated user's cart.
- CheckoutAccessTest::setUp in modules/
checkout/ tests/ src/ Kernel/ CheckoutAccessTest.php - CheckoutOrderTest::testCheckoutRedirect in modules/
checkout/ tests/ src/ Functional/ CheckoutOrderTest.php - Tests the checkout redirect route.
File
- modules/
store/ src/ StoreCreationTrait.php, line 35
Class
- StoreCreationTrait
- Provides methods to create stores and set the default store.
Namespace
Drupal\commerce_storeCode
protected function createStore($name = NULL, $mail = NULL, $type = 'online', $default = TRUE, $country = 'US', $currency = 'USD') {
if (!$name) {
$name = $this
->randomMachineName(8);
}
if (!$mail) {
$mail = \Drupal::currentUser()
->getEmail();
}
$currency_importer = \Drupal::service('commerce_price.currency_importer');
$currency_importer
->import($currency);
$store = Store::create([
'type' => $type,
'uid' => 1,
'name' => $name,
'mail' => $mail,
'default_currency' => $currency,
'timezone' => 'Australia/Sydney',
'address' => [
'country_code' => $country,
'address_line1' => $this
->randomString(),
'locality' => $this
->randomString(5),
'administrative_area' => 'WI',
'postal_code' => '53597',
],
'billing_countries' => [
$country,
],
'is_default' => $default,
]);
$store
->save();
$store = Store::load($store
->id());
return $store;
}