Every test creates a store and needs a store. We need a trait for making stores and setting the default store. Something like
/**
* Creates and sets the default store.
*
* @return \Drupal\commerce_store\Entity\StoreInterface
* The store.
*/
protected function createDefaultStore() {
$currency_importer = \Drupal::service('commerce_price.currency_importer');
/** @var \Drupal\commerce_store\StoreStorage $store_storage */
$store_storage = \Drupal::service('entity_type.manager')->getStorage('commerce_store');
$currency_importer->import('USD');
$store_values = [
'type' => 'default',
'uid' => 1,
'name' => 'Demo store',
'mail' => 'admin@example.com',
'address' => [
'country_code' => 'US',
],
'default_currency' => 'USD',
'billing_countries' => [
'US',
],
];
$store = $store_storage->create($store_values);
$store->save();
$store_storage->markAsDefault($store);
return $store;
}
Comments
Comment #2
mglamanPR: https://github.com/drupalcommerce/commerce/pull/390
Comment #4
bojanz commentedBoom.