You are here

public function PatternMatchingTest::patternProvider in Config Ignore 8.2

Get the ignored config and test against the names.

Return value

array The patterns and what should and shouldn't match.

File

tests/src/Unit/PatternMatchingTest.php, line 51

Class

PatternMatchingTest
Test the pattern matching.

Namespace

Drupal\Tests\config_ignore\Unit

Code

public function patternProvider() {

  // For each pattern there needs to be a positive and a negative case.
  return [
    'system.site ignored' => [
      [
        'system.site',
      ],
      [
        'system.site' => TRUE,
        'system.performance' => FALSE,
      ],
    ],
    'system ignored' => [
      [
        'system.*',
      ],
      [
        'system.site' => TRUE,
        'system.performance' => TRUE,
        'node.site' => FALSE,
      ],
    ],
    'site ignored' => [
      [
        '*.site',
      ],
      [
        'system.site' => TRUE,
        'system.performance' => FALSE,
        'other.site' => TRUE,
      ],
    ],
    'node ignored' => [
      [
        'node.*',
      ],
      [
        'system.site' => FALSE,
        'node.settings' => TRUE,
        'node.settings.other' => TRUE,
      ],
    ],
    'middle ignored' => [
      [
        'start.*.end',
      ],
      [
        'start.something' => FALSE,
        'start.something.end' => TRUE,
        'start.something.else.end' => TRUE,
        'start.something.ending' => FALSE,
      ],
    ],
    'enforced excluded' => [
      [
        'system.*',
        '~system.site',
      ],
      [
        'system.site' => FALSE,
        'system.performance' => TRUE,
      ],
    ],
    'system sub-key ignored' => [
      [
        'system.*:foo',
      ],
      [
        'system.site' => TRUE,
        'system.performance' => TRUE,
        'node.foo' => FALSE,
      ],
    ],
  ];
}