You are here

protected function CommerceExchangerCalculatorTest::setUp in Commerce Exchanger 8

Overrides CommerceKernelTestBase::setUp

File

tests/src/Kernel/CommerceExchangerCalculatorTest.php, line 58

Class

CommerceExchangerCalculatorTest
Tests the exchanger calculator.

Namespace

Drupal\Tests\commerce_exchanger\Kernel

Code

protected function setUp() {
  parent::setUp();

  // The parent has already imported USD.
  $currency_importer = $this->container
    ->get('commerce_price.currency_importer');
  $currency_importer
    ->import('HRK');
  $this->priceHrk = new Price('100', 'HRK');
  $this->priceUsd = new Price('100', 'USD');
  $exchanger = ExchangeRates::create([
    'label' => 'ECB Rate',
    'id' => 'ecb_rates',
    'plugin' => 'ecb',
    'status' => TRUE,
  ]);
  $exchanger
    ->save();
  $this->exchanger = $exchanger;
  $this->exchangerId = $exchanger
    ->getExchangerConfigName();
  $this
    ->config($this->exchangerId)
    ->setData([
    'rates' => [
      'HRK' => [
        'USD' => [
          'value' => 0.15,
          'sync' => 0,
        ],
      ],
      'USD' => [
        'HRK' => [
          'value' => 6.85,
          'sync' => 0,
        ],
      ],
    ],
  ])
    ->save();
}