/**
  * @covers ::loadConfiguration
  */
 public function testLoadConfiguration()
 {
     $plugin_id_a = $this->randomMachineName();
     $plugin_id_b = $this->randomMachineName();
     $plugin_definitions = array($plugin_id_a => array(), $plugin_id_b => array());
     $config_value = array(array('plugin_id' => $plugin_id_b, 'status' => TRUE));
     $this->currencyExchangeRateProviderManager->expects($this->once())->method('getDefinitions')->willReturn($plugin_definitions);
     $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
     $config->expects($this->once())->method('get')->with('plugins')->willReturn($config_value);
     $this->configFactory->expects($this->once())->method('get')->with('currency.exchange_rate_provider')->willReturn($config);
     $configuration = $this->sut->loadConfiguration();
     $expected = array($plugin_id_b => TRUE, $plugin_id_a => FALSE);
     $this->assertSame($expected, $configuration);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $definitions = $this->currencyExchangeRateProviderManager->getDefinitions();
     $configuration = $this->exchangeRateProvider->loadConfiguration();
     $form['exchange_rate_providers'] = array('#header' => array($this->t('Title'), $this->t('Enabled'), $this->t('Weight'), $this->t('Operations')), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'form-select')), '#type' => 'table');
     $weight = 0;
     foreach ($configuration as $plugin_id => $enabled) {
         $weight++;
         $plugin_definition = $definitions[$plugin_id];
         $form['exchange_rate_providers'][$plugin_id] = array('#attributes' => array('class' => array('draggable')), '#weight' => $weight);
         $form['exchange_rate_providers'][$plugin_id]['label'] = array('#description' => $plugin_definition['description'], '#markup' => $plugin_definition['label'], '#title' => $this->t('Title'), '#title_display' => 'invisible', '#type' => 'item');
         $form['exchange_rate_providers'][$plugin_id]['enabled'] = array('#default_value' => $enabled, '#title' => $this->t('Enabled'), '#title_display' => 'invisible', '#type' => 'checkbox');
         $form['exchange_rate_providers'][$plugin_id]['weight'] = array('#default_value' => $weight, '#title' => $this->t('Weight'), '#title_display' => 'invisible', '#type' => 'weight');
         $operations_provider = $this->currencyExchangeRateProviderManager->getOperationsProvider($plugin_id);
         $form['exchange_rate_providers'][$plugin_id]['operations'] = array('#links' => $operations_provider ? $operations_provider->getOperations($plugin_id) : [], '#title' => $this->t('Operations'), '#type' => 'operations');
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['save'] = array('#button_type' => 'primary', '#type' => 'submit', '#value' => $this->t('Save'));
     return $form;
 }