You are here

public function ConfigImporterTest::testGetImportableCurrencyLocales in Currency 8.3

@covers ::getImportableCurrencyLocales

File

tests/src/Unit/ConfigImporterTest.php, line 169

Class

ConfigImporterTest
@coversDefaultClass \Drupal\currency\ConfigImporter

Namespace

Drupal\Tests\currency\Unit

Code

public function testGetImportableCurrencyLocales() {
  $locale_a = $this
    ->randomMachineName();
  $currency_locale_a = $this
    ->createMock(CurrencyLocaleInterface::class);
  $locale_b = $this
    ->randomMachineName();
  $currency_locale_b = $this
    ->createMock(CurrencyLocaleInterface::class);
  $locale_c = $this
    ->randomMachineName();
  $currency_locale_data_c = [
    'id' => $locale_c,
  ];
  $currency_locale_c = $this
    ->createMock(CurrencyLocaleInterface::class);
  $stored_currencies = [
    $locale_a => $currency_locale_a,
    $locale_b => $currency_locale_b,
  ];
  $this->currencyLocaleStorage
    ->expects($this
    ->atLeastOnce())
    ->method('create')
    ->with($currency_locale_data_c)
    ->willReturn($currency_locale_c);
  $this->currencyLocaleStorage
    ->expects($this
    ->atLeastOnce())
    ->method('loadMultiple')
    ->with(NULL)
    ->willReturn($stored_currencies);
  $prefix = 'currency.currency_locale.';
  $this->configStorage
    ->expects($this
    ->atLeastOnce())
    ->method('listAll')
    ->with($prefix)
    ->willReturn([
    $prefix . $locale_b,
    $prefix . $locale_c,
  ]);
  $this->configStorage
    ->expects($this
    ->once())
    ->method('read')
    ->with($prefix . $locale_c)
    ->willReturn($currency_locale_data_c);
  $this->sut
    ->setConfigStorage($this->configStorage);
  $importable_currencies = $this->sut
    ->getImportableCurrencyLocales();
  $this
    ->assertSame([
    $currency_locale_c,
  ], $importable_currencies);
}