public function StatusOverrideTest::testStateConfigOverride in Configuration Split 2.0.x
Test the status override service.
File
- tests/
src/ Kernel/ StatusOverrideTest.php, line 28
Class
- StatusOverrideTest
- Test the config split status override service.
Namespace
Drupal\Tests\config_split\KernelCode
public function testStateConfigOverride() {
$this
->createSplitConfig('active', [
'status' => TRUE,
])
->save();
$this
->createSplitConfig('inactive', [
'status' => FALSE,
])
->save();
/** @var \Drupal\config_split\Config\StatusOverride $override */
$override = $this->container
->get('config_split.status_override');
/** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */
$configFactory = $this->container
->get('config.factory');
self::assertNull($override
->getSplitOverride('active'));
self::assertNull($override
->getSplitOverride('inactive'));
self::assertTrue($configFactory
->get('config_split.config_split.active')
->get('status'));
self::assertFalse($configFactory
->get('config_split.config_split.inactive')
->get('status'));
$override
->setSplitOverride('active', FALSE);
$override
->setSplitOverride('inactive', TRUE);
$configFactory
->clearStaticCache();
self::assertFalse($override
->getSplitOverride('active'));
self::assertFalse($configFactory
->get('config_split.config_split.active')
->get('status'));
self::assertTrue($override
->getSplitOverride('inactive'));
self::assertTrue($configFactory
->get('config_split.config_split.inactive')
->get('status'));
$override
->setSplitOverride('active', NULL);
$override
->setSplitOverride('inactive', NULL);
$configFactory
->clearStaticCache();
self::assertNull($override
->getSplitOverride('active'));
self::assertNull($override
->getSplitOverride('inactive'));
self::assertTrue($configFactory
->get('config_split.config_split.active')
->get('status'));
self::assertFalse($configFactory
->get('config_split.config_split.inactive')
->get('status'));
}