class FileStorageFactoryTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php \Drupal\KernelTests\Core\Config\FileStorageFactoryTest
- 10 core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php \Drupal\KernelTests\Core\Config\FileStorageFactoryTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php \Drupal\KernelTests\Core\Config\FileStorageFactoryTest
@coversDefaultClass \Drupal\Core\Config\FileStorageFactory
@group config
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Config\FileStorageFactoryTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of FileStorageFactoryTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ FileStorageFactoryTest.php, line 15
Namespace
Drupal\KernelTests\Core\ConfigView source
class FileStorageFactoryTest extends KernelTestBase {
/**
* @covers ::getSync
*/
public function testGetSync() {
// Write some random data to the sync storage.
$name = $this->randomMachineName();
$data = (array) $this->getRandomGenerator()
->object();
$storage = new FileStorage(Settings::get('config_sync_directory'));
$storage->write($name, $data);
// Get the sync storage and read from it.
$sync = FileStorageFactory::getSync();
$this->assertEquals($data, $sync->read($name));
// Unset the sync directory setting.
$settings = Settings::getInstance() ? Settings::getAll() : [];
unset($settings['config_sync_directory']);
new Settings($settings);
// On an empty settings there is an exception thrown.
$this->expectException(ConfigDirectoryNotDefinedException::class);
$this->expectExceptionMessage('The config sync directory is not defined in $settings["config_sync_directory"]');
FileStorageFactory::getSync();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.