You are here

public function FixedRatesTest::testSave in Currency 8.3

@covers ::save

File

tests/src/Unit/Plugin/Currency/ExchangeRateProvider/FixedRatesTest.php, line 131

Class

FixedRatesTest
@coversDefaultClass \Drupal\currency\Plugin\Currency\ExchangeRateProvider\FixedRates

Namespace

Drupal\Tests\currency\Unit\Plugin\Currency\ExchangeRateProvider

Code

public function testSave() {
  $currency_code_from = $this
    ->randomMachineName(3);
  $currency_code_to = $this
    ->randomMachineName(3);
  $rate = mt_rand();
  list($rates, $rates_data) = $this
    ->prepareExchangeRates();
  $rates[$currency_code_from][$currency_code_to] = $rate;
  $rates_data[] = array(
    'currency_code_from' => $currency_code_from,
    'currency_code_to' => $currency_code_to,
    'rate' => $rate,
  );
  $this->config
    ->expects($this
    ->once())
    ->method('set')
    ->with('rates', $rates_data);
  $this->config
    ->expects($this
    ->once())
    ->method('save');
  $this->sut
    ->save($currency_code_from, $currency_code_to, $rate);
}