You are here

public function ExchangeRateProviderDecoratorTest::testLoadMultiple in Currency 8.3

@covers ::loadMultiple

File

tests/src/Unit/Plugin/Currency/ExchangeRateProvider/ExchangeRateProviderDecoratorTest.php, line 72

Class

ExchangeRateProviderDecoratorTest
@coversDefaultClass \Drupal\currency\Plugin\Currency\ExchangeRateProvider\ExchangeRateProviderDecorator

Namespace

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

Code

public function testLoadMultiple() {
  $source_currency_code = $this
    ->randomMachineName();
  $destination_currency_code_a = $this
    ->randomMachineName();
  $destination_currency_code_b = $this
    ->randomMachineName();
  $exchange_rate_a = new ExchangeRate($source_currency_code, $destination_currency_code_a, mt_rand(), $this->pluginId);
  $exchange_rate_b = new ExchangeRate($source_currency_code, $destination_currency_code_b, mt_rand(), $this->pluginId);
  $exchange_rates = [
    $source_currency_code => [
      $destination_currency_code_a => $exchange_rate_a,
      $destination_currency_code_b => $exchange_rate_b,
    ],
  ];
  $this->exchangeRateProvider
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->with([
    $source_currency_code => [
      $destination_currency_code_a,
      $destination_currency_code_b,
    ],
  ])
    ->willReturn($exchange_rates);
  $loaded_exchange_rates = $this->sut
    ->loadMultiple([
    $source_currency_code => [
      $destination_currency_code_a,
      $destination_currency_code_b,
    ],
  ]);
  $this
    ->assertExchangeRateEquals($exchange_rate_a, $loaded_exchange_rates[$source_currency_code][$destination_currency_code_a]);
  $this
    ->assertExchangeRateEquals($exchange_rate_b, $loaded_exchange_rates[$source_currency_code][$destination_currency_code_b]);
}