public function SplitFilterTest::testBlacklist in Configuration Split 8
Test that the blacklist is correctly calculated.
File
- src/
Tests/ SplitFilterTest.php, line 25
Class
- SplitFilterTest
- Test filter plugin.
Namespace
Drupal\config_split\TestsCode
public function testBlacklist() {
$configuration = [];
$configuration['blacklist'] = [
'a',
'b',
];
$configuration['graylist'] = [];
$configuration['module'] = [
'module1' => 0,
'module2' => 0,
];
$configuration['theme'] = [
'theme1' => 0,
];
$configuration['graylist_dependents'] = FALSE;
// The config manager returns dependent entities for modules and themes.
$manager = $this
->prophesize('Drupal\\Core\\Config\\ConfigManagerInterface');
$manager
->findConfigEntityDependents(Argument::exact('module'), Argument::exact([
'module1',
'module2',
]))
->willReturn([
'c' => 0,
'd' => 0,
'a' => 0,
]);
$manager
->findConfigEntityDependents(Argument::exact('theme'), Argument::exact([
'theme1',
]))
->willReturn([
'e' => 0,
'f' => 0,
'c' => 0,
]);
// Add a config storage returning some settings for the filtered modules.
$all_config = array_merge(array_fill_keys(range("a", "z"), []), [
'module1.settings' => [],
'module3.settings' => [],
]);
$manager
->getConfigFactory()
->willReturn($this
->getConfigStorageStub($all_config));
// Add more config dependencies, independently of what is asked for.
$manager
->findConfigEntityDependents(Argument::exact('config'), Argument::cetera())
->willReturn([
'f' => 0,
'g' => 0,
'b' => 0,
]);
$filter = new SplitFilter($configuration, 'config_split', [], $manager
->reveal());
$actual = $filter
->getBlacklist();
// The order of values and keys are not important.
sort($actual);
$expected = [
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'module1.settings',
];
$this
->assertArrayEquals($expected, $actual);
}