You are here

public function PluginBasedExchangeRateProviderTest::testSaveConfiguration in Currency 8.3

@covers ::saveConfiguration

File

tests/src/Unit/PluginBasedExchangeRateProviderTest.php, line 100

Class

PluginBasedExchangeRateProviderTest
@coversDefaultClass \Drupal\currency\PluginBasedExchangeRateProvider

Namespace

Drupal\Tests\currency\Unit

Code

public function testSaveConfiguration() {
  $configuration = array(
    'currency_historical_rates' => TRUE,
    'currency_fixed_rates' => TRUE,
    'foo' => FALSE,
  );
  $configuration_data = array(
    array(
      'plugin_id' => 'currency_historical_rates',
      'status' => TRUE,
    ),
    array(
      'plugin_id' => 'currency_fixed_rates',
      'status' => TRUE,
    ),
    array(
      'plugin_id' => 'foo',
      'status' => FALSE,
    ),
  );
  $config = $this
    ->getMockBuilder(Config::class)
    ->disableOriginalConstructor()
    ->getMock();
  $config
    ->expects($this
    ->once())
    ->method('set')
    ->with('plugins', $configuration_data);
  $config
    ->expects($this
    ->once())
    ->method('save');
  $this->configFactory
    ->expects($this
    ->once())
    ->method('getEditable')
    ->with('currency.exchange_rate_provider')
    ->willReturn($config);
  $this->sut
    ->saveConfiguration($configuration);
}