You are here

public function ConfigIgnorePatternResolverTest::testGetIgnoredConfigs in Config Ignore 8.3

Tests the config ignore pattern resolver.

@covers ::getIgnoredConfigs

Throws

\ReflectionException If the class does not exist.

File

tests/src/Unit/ConfigIgnorePatternResolverTest.php, line 72

Class

ConfigIgnorePatternResolverTest
Tests the config ignore pattern resolver.

Namespace

Drupal\Tests\config_ignore\Unit

Code

public function testGetIgnoredConfigs() {
  $ignoredConfigs = $this
    ->getIgnoredConfigs([
    // Non-existing simple ignore pattern.
    'non.existing',
    // Simple ignore pattern.
    'foo.bar',
    // Suffix wildcard ignore pattern.
    'foo.bar.*',
    // Excluding foo.bar.suffix4.
    '~foo.bar.suffix4',
    // Prefix wildcard ignore pattern.
    '*.foo.bar',
    // Excluding prefix2.foo.bar.
    '~prefix2.foo.bar',
    // Middle wildcard ignore pattern.
    'foo.*.bar',
    // Excluding foo.middle1.bar.
    '~foo.middle1.bar',
    // Ignore pattern with key.
    'foo.baz.qux:path.to.key',
    // A 2nd key of the same config is appended.
    'foo.baz.qux:a.second.key',
    // Ignore pattern with key when the same config has been already added.
    'foo.bar:some.key',
    // Ignore pattern with key that will be overwritten later with the same
    // config but without key.
    'baz.qux:with.some.key',
    // Only this will be outputted as it covers also the one with a key.
    'baz.qux',
  ], [
    'foo.bar',
    'foo.bar.suffix1',
    'foo.bar.suffix2',
    'foo.bar.suffix3',
    'foo.bar.suffix4',
    'prefix1.foo.bar',
    'prefix2.foo.bar',
    'prefix3.foo.bar',
    'foo.middle1.bar',
    'foo.middle2.bar',
    'foo.middle3.bar',
    'foo.baz.qux',
    'baz.qux',
  ]);
  $this
    ->assertSame([
    'foo.bar' => NULL,
    'foo.bar.suffix1' => NULL,
    'foo.bar.suffix2' => NULL,
    'foo.bar.suffix3' => NULL,
    'prefix1.foo.bar' => NULL,
    'prefix3.foo.bar' => NULL,
    'foo.middle2.bar' => NULL,
    'foo.middle3.bar' => NULL,
    'foo.baz.qux' => [
      [
        'path',
        'to',
        'key',
      ],
      [
        'a',
        'second',
        'key',
      ],
    ],
    'baz.qux' => NULL,
  ], $ignoredConfigs);
}