You are here

public function FormOverridesTest::providerFormOverrides in Configuration Override Warn 8

Data provider for testing form overrides.

Return value

array An array of test cases.

File

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

Class

FormOverridesTest
Tests module overrides of configuration using event subscribers.

Namespace

Drupal\Tests\config_override_warn\Kernel

Code

public function providerFormOverrides() {
  return [
    // Test with show_values turned on, show that both name and slogan are
    // overridden with their original and overridden values.
    [
      [
        'system.site' => [
          'name' => 'Original name',
          'slogan' => 'Original slogan',
        ],
        'config_override_warn.settings' => [
          'show_values' => TRUE,
        ],
      ],
      SiteInformationForm::class,
      [
        'system.site' => [
          'name' => [
            'original' => '\'Original name\'',
            'override' => '\'ZOMG overridden site name\'',
          ],
          'slogan' => [
            'original' => '\'Original slogan\'',
            'override' => '\'Yay for overrides!\'',
          ],
        ],
      ],
      TRUE,
    ],
    // Test the same as above just with only the name being overridden.
    [
      [
        'system.site' => [
          'name' => 'Original name',
          'slogan' => 'Yay for overrides!',
        ],
        'config_override_warn.settings' => [
          'show_values' => TRUE,
        ],
      ],
      SiteInformationForm::class,
      [
        'system.site' => [
          'name' => [
            'original' => '\'Original name\'',
            'override' => '\'ZOMG overridden site name\'',
          ],
        ],
      ],
      TRUE,
    ],
    // With show_values turned off (default), we should just see that the
    // name and slogan values are overridden, without values.
    [
      [],
      SiteInformationForm::class,
      [
        'system.site' => [
          'name' => NULL,
          'slogan' => NULL,
        ],
      ],
      TRUE,
    ],
    // Test the same as above just with only the slogan being overridden.
    [
      [
        'system.site' => [
          'name' => 'ZOMG overridden site name',
        ],
      ],
      SiteInformationForm::class,
      [
        'system.site' => [
          'slogan' => NULL,
        ],
      ],
      TRUE,
    ],
    // Test with no overrides.
    [
      [],
      SiteInformationForm::class,
      [],
      FALSE,
    ],
  ];
}