3 namespace Drupal\Tests\Core\Config;
5 use Drupal\Core\Config\ImmutableConfig;
6 use Drupal\Core\Config\ImmutableConfigException;
7 use Drupal\Tests\UnitTestCase;
10 * @coversDefaultClass \Drupal\Core\Config\ImmutableConfig
13 class ImmutableConfigTest extends UnitTestCase {
16 * The immutable config object under test.
18 * @var \Drupal\Core\Config\ImmutableConfig
22 protected function setUp() {
24 $storage = $this->getMock('Drupal\Core\Config\StorageInterface');
25 $event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
26 $typed_config = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
27 $this->config = new ImmutableConfig('test', $storage, $event_dispatcher, $typed_config);
33 public function testSet() {
34 $this->setExpectedException(ImmutableConfigException::class, 'Can not set values on immutable configuration test:name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object');
35 $this->config->set('name', 'value');
41 public function testClear() {
42 $this->setExpectedException(ImmutableConfigException::class, 'Can not clear name key in immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object');
43 $this->config->clear('name');
49 public function testSave() {
50 $this->setExpectedException(ImmutableConfigException::class, 'Can not save immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object');
51 $this->config->save();
57 public function testDelete() {
58 $this->setExpectedException(ImmutableConfigException::class, 'Can not delete immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object');
59 $this->config->delete();