ManagedStorageTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Drupal\KernelTests\Core\Config\Storage;
  3. use Drupal\Core\Config\StorageManagerInterface;
  4. use Drupal\Core\Config\ManagedStorage;
  5. use Drupal\Core\Config\MemoryStorage;
  6. /**
  7. * Tests ManagedStorage operations.
  8. *
  9. * @group config
  10. */
  11. class ManagedStorageTest extends ConfigStorageTestBase implements StorageManagerInterface {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function getStorage() {
  16. // We return a new storage every time to make sure the managed storage
  17. // only calls this once and retains the configuration by itself.
  18. return new MemoryStorage();
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected function setUp() {
  24. parent::setUp();
  25. $this->storage = new ManagedStorage($this);
  26. // ::listAll() verifications require other configuration data to exist.
  27. $this->storage->write('system.performance', []);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function read($name) {
  33. return $this->storage->read($name);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. protected function insert($name, $data) {
  39. $this->storage->write($name, $data);
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. protected function update($name, $data) {
  45. $this->storage->write($name, $data);
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. protected function delete($name) {
  51. $this->storage->delete($name);
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function testInvalidStorage() {
  57. $this->markTestSkipped('ManagedStorage cannot be invalid.');
  58. }
  59. }