You are here

public function FormOverridesTest::testFormOverrides in Configuration Override Warn 8

Test overridden values.

@dataProvider providerFormOverrides

Parameters

array $config_to_set: Any configuration that needs to be set.

string $form_class: The form class name to use.

array $expected_overrides: The expected value from the getFormOverrides() method.

bool $override_flag: The override flag to set.

File

tests/src/Kernel/FormOverridesTest.php, line 51

Class

FormOverridesTest
Tests module overrides of configuration using event subscribers.

Namespace

Drupal\Tests\config_override_warn\Kernel

Code

public function testFormOverrides(array $config_to_set, $form_class, array $expected_overrides, $override_flag) {
  foreach ($config_to_set as $config_name => $values) {
    $config = $this
      ->config($config_name);
    foreach ($values as $key => $value) {
      $config
        ->set($key, $value);
    }
    $config
      ->save(TRUE);
  }
  $GLOBALS['config_test_run_module_overrides'] = $override_flag;
  $form = \Drupal::classResolver($form_class);
  $overrides = $this->container
    ->get('config_override_warn.form_overrides')
    ->getFormOverrides($form);
  $this
    ->assertSame($expected_overrides, $overrides);
  unset($GLOBALS['config_test_run_module_overrides']);
}