ExampleStorageKernelTest.php in Config Filter 8
File
tests/src/Kernel/ExampleStorageKernelTest.php
View source
<?php
namespace Drupal\Tests\config_filter\Kernel;
use Drupal\Core\Config\MemoryStorage;
use Drupal\KernelTests\KernelTestBase;
class ExampleStorageKernelTest extends KernelTestBase {
use ConfigStorageTestTrait;
public static $modules = [
'system',
'config_filter',
'config_filter_test',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'system',
]);
$this
->config('system.site')
->set('name', 'Config Test')
->set('slogan', 'Testing is fun!')
->save();
}
public function testExampleExport() {
$expectedExport = new MemoryStorage();
$this
->copyConfig($this
->getActiveStorage(), $expectedExport);
$system_site = $expectedExport
->read('system.site');
$system_site['slogan'] = 'Testing is fun! Arrr';
$expectedExport
->write('system.site', $system_site);
static::assertStorageEquals($expectedExport, $this
->getExportStorage());
}
public function testExampleImport() {
$this
->copyConfig($this
->getActiveStorage(), $this
->getSyncFileStorage());
$expectedImport = new MemoryStorage();
$this
->copyConfig($this
->getSyncFileStorage(), $expectedImport);
$system_site = $expectedImport
->read('system.site');
$system_site['name'] = 'Config Test Arrr';
$expectedImport
->write('system.site', $system_site);
static::assertStorageEquals($expectedImport, $this
->getImportStorage());
}
}