You are here

public function SplitFilterTest::testWildcards in Configuration Split 8

Test that the wildcards are properly taken into account.

@dataProvider wildcardsData

File

src/Tests/SplitFilterTest.php, line 120

Class

SplitFilterTest
Test filter plugin.

Namespace

Drupal\config_split\Tests

Code

public function testWildcards($name, $method) {
  $list = [
    'a',
    'b',
    'contact*',
    '*.d',
    'e*i',
    'f*de*',
    'x',
  ];
  $configuration = [];
  $configuration['blacklist'] = [];
  $configuration['graylist'] = [];
  $configuration['module'] = [];
  $configuration['theme'] = [];
  $configuration['graylist_dependents'] = TRUE;
  $configuration[$name] = $list;

  // The config manager returns dependent entities for modules and themes.
  $manager = $this
    ->prophesize('Drupal\\Core\\Config\\ConfigManagerInterface');
  $manager
    ->findConfigEntityDependents(Argument::exact('module'), Argument::cetera())
    ->willReturn([]);
  $manager
    ->findConfigEntityDependents(Argument::exact('theme'), Argument::cetera())
    ->willReturn([]);

  // Add a config storage returning some settings for the filtered modules.
  $all_config = array_merge(array_fill_keys(range("a", "z"), []), [
    'contact' => [],
    'contacts' => [],
    'contact.form' => [],
    'form' => [],
    'form.d' => [],
    'form.demo' => [],
    'formed' => [],
    'ei' => [],
    'efi' => [],
    'efghi' => [],
    'efghijk' => [],
    'abcdefghijk' => [],
  ]);
  $manager
    ->getConfigFactory()
    ->willReturn($this
    ->getConfigStorageStub($all_config));
  $expected = [
    'a',
    'b',
    'contact',
    'contact.form',
    'contacts',
    'efghi',
    'efi',
    'ei',
    'form.d',
    'form.demo',
    'x',
  ];
  $manager
    ->findConfigEntityDependents(Argument::exact('config'), Argument::exact($expected))
    ->willReturn([]);
  $manager
    ->findConfigEntityDependents(Argument::exact('config'), Argument::exact([]))
    ->willReturn([]);
  $filter = new SplitFilter($configuration, 'config_split', [], $manager
    ->reveal());
  $actual = $filter
    ->{$method}();
  $this
    ->assertArrayEquals($expected, $actual);
}