View source
<?php
namespace Drupal\Tests\commerce_currency_resolver\FunctionalJavascript;
use Drupal\commerce_exchanger\Entity\ExchangeRates;
use Drupal\Tests\commerce_order\FunctionalJavascript\OrderAdminTest;
class CurrentCurrencyOrderAdminTest extends OrderAdminTest {
protected $currentCurrency;
public static $modules = [
'commerce_exchanger',
'commerce_currency_resolver',
'commerce_test',
'commerce_currency_resolver_test',
];
protected function setUp() {
parent::setUp();
$currency_importer = $this->container
->get('commerce_price.currency_importer');
$currency_importer
->import('VUV');
$exchange_rates = ExchangeRates::create([
'id' => 'testing',
'label' => 'Manual',
'plugin' => 'manual',
'status' => TRUE,
'configuration' => [
'cron' => FALSE,
'use_cross_sync' => FALSE,
'demo_amount' => 100,
'base_currency' => 'USD',
'mode' => 'live',
],
]);
$exchange_rates
->save();
$this
->config($exchange_rates
->getExchangerConfigName())
->setData([
'rates' => [
'VUV' => [
'USD' => [
'value' => 0.00878642,
'sync' => 0,
],
],
'USD' => [
'VUV' => [
'value' => 113.812,
'sync' => 0,
],
],
],
])
->save();
$this
->config('commerce_currency_resolver.settings')
->set('currency_exchange_rates', 'testing')
->set('currency_default', 'VUV')
->set('currency_mapping', 'cookie')
->save();
$this->store
->setDefaultCurrencyCode('USD');
$this->store
->save();
$this
->reloadEntity($this->store);
$this->currentCurrency = $this->container
->get('commerce_currency_resolver.current_currency');
}
public function testCreateOrder() {
$this
->drupalGet('/admin/commerce/orders');
$this
->assertEqual($this->store
->getDefaultCurrencyCode(), 'USD');
$this
->assertEqual($this->currentCurrency
->getCurrency(), 'VUV');
$this
->assertEqual(\Drupal::service('commerce_currency_resolver.current_currency')
->getCurrency(), 'VUV');
parent::testCreateOrder();
}
}