public function SplitFilterTest::testGraylist in Configuration Split 8
Test that the graylist is correctly calculated.
File
- src/
Tests/ SplitFilterTest.php, line 57
Class
- SplitFilterTest
- Test filter plugin.
Namespace
Drupal\config_split\TestsCode
public function testGraylist() {
$configuration = [];
$configuration['blacklist'] = [];
$configuration['graylist'] = [
'a',
'b',
];
$configuration['module'] = [];
$configuration['theme'] = [];
$configuration['graylist_dependents'] = TRUE;
// 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"), []), [
'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::exact([]))
->willReturn([]);
$manager
->findConfigEntityDependents(Argument::exact('config'), Argument::exact([
'a',
'b',
]))
->willReturn([
'f' => 0,
'g' => 0,
'b' => 0,
]);
$filter = new SplitFilter($configuration, 'config_split', [], $manager
->reveal());
$actual = $filter
->getGraylist();
// The order of values and keys are not important.
sort($actual);
$this
->assertArrayEquals([
'a',
'b',
'f',
'g',
], $actual);
}