Skip to content
Snippets Groups Projects
Commit 245345b4 authored by Bojan Živanović's avatar Bojan Živanović
Browse files

Issue #2910188 by bojanz: Import an initial currency when commerce_price is installed

parent f009693c
No related branches found
Tags 8.x-2.0-beta1
No related merge requests found
......@@ -21,3 +21,15 @@ function commerce_price_requirements($phase) {
return $requirements;
}
/**
* Implements hook_install().
*/
function commerce_price_install() {
// Import a currency to speed up initial store setup.
// If no default country is set, import the US Dollar, since it's common.
$default_country = \Drupal::config('system.date')->get('country.default');
$default_country = $default_country ?: 'US';
$currency_importer = \Drupal::service('commerce_price.currency_importer');
$currency_importer->importByCountry($default_country);
}
......@@ -13,6 +13,15 @@ use Drupal\Core\Url;
*/
class CurrencyTest extends CommerceBrowserTestBase {
/**
* Tests the initial currency creation.
*/
public function testInitialCurrency() {
// We are expecting commerce_price_install() to import 'USD'.
$currency = Currency::load('USD');
$this->assertNotEmpty($currency);
}
/**
* Tests importing a currency.
*/
......
......@@ -61,9 +61,6 @@ abstract class CommerceBrowserTestBase extends BrowserTestBase {
$this->adminUser = $this->drupalCreateUser($this->getAdministratorPermissions());
$this->drupalLogin($this->adminUser);
$currency_importer = \Drupal::service('commerce_price.currency_importer');
$currency_importer->import('USD');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment