You are here

public function FormOverridesTest::testConfigEntityOverrides in Configuration Override Warn 8

Test config entity form overridden values.

@dataProvider providerConfigEntityOverrides

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 175

Class

FormOverridesTest
Tests module overrides of configuration using event subscribers.

Namespace

Drupal\Tests\config_override_warn\Kernel

Code

public function testConfigEntityOverrides(array $config_to_set, $form_class, $entity_type, $entity_id, 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['it_is_pirate_day'] = $override_flag;

  /** @var \Drupal\Core\Entity\EntityFormInterface $form */
  $form = \Drupal::classResolver($form_class);
  $entity = $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type)
    ->load($entity_id);
  $form
    ->setEntity($entity);
  $overrides = $this->container
    ->get('config_override_warn.form_overrides')
    ->getFormOverrides($form);
  $this
    ->assertSame($expected_overrides, $overrides);
  unset($GLOBALS['it_is_pirate_day']);
}