Commit 1c3da39d authored by bircher's avatar bircher

Issue #2958832 by bircher: Move GhostStorage from config_split to config_filter

parent 66a090ea
<?php
namespace Drupal\config_filter\Config;
use Drupal\Core\Config\StorageInterface;
/**
* Class GhostStorage.
*
* A GhostStorage acts like the normal Storage it wraps. All reading operations
* return the values of the decorated storage but write operations are silently
* ignored and the ghost pretends that the operation was successful.
*
* @package Drupal\config_filter\Config
*/
class GhostStorage extends ReadOnlyStorage implements StorageInterface {
/**
* {@inheritdoc}
*/
public function write($name, array $data) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function delete($name) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function rename($name, $new_name) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function deleteAll($prefix = '') {
return TRUE;
}
}
<?php
namespace Drupal\config_filter\Tests;
use Drupal\config_filter\Config\GhostStorage;
use Drupal\Core\Config\StorageInterface;
use Prophecy\Argument;
/**
* Tests GhostStorage operations.
*
* @group config_filter
*/
class GhostStorageTest extends ReadonlyStorageTest {
/**
* Override the storage decorating.
*
* @param \Drupal\Core\Config\StorageInterface $source
* The storage to decorate.
*
* @return \Drupal\config_filter\Config\GhostStorage
* The storage to test.
*/
protected function getStorage(StorageInterface $source) {
return new GhostStorage($source);
}
/**
* Override the dataprovider for write methods.
*
* @dataProvider writeMethodsProvider
*/
public function testWriteOperations($method, $arguments) {
$source = $this->prophesize(StorageInterface::class);
$source->$method(Argument::any())->shouldNotBeCalled();
$storage = $this->getStorage($source->reveal());
$actual = call_user_func_array([$storage, $method], $arguments);
$this->assertTrue($actual);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment