Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Config / ImmutableConfigTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Config;
4
5 use Drupal\Core\Config\ImmutableConfig;
6 use Drupal\Core\Config\ImmutableConfigException;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Config\ImmutableConfig
11  * @group Config
12  */
13 class ImmutableConfigTest extends UnitTestCase {
14
15   /**
16    * The immutable config object under test.
17    *
18    * @var \Drupal\Core\Config\ImmutableConfig
19    */
20   protected $config;
21
22   protected function setUp() {
23     parent::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);
28   }
29
30   /**
31    * @covers ::set
32    */
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');
36   }
37
38   /**
39    * @covers ::clear
40    */
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');
44   }
45
46   /**
47    * @covers ::save
48    */
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();
52   }
53
54   /**
55    * @covers ::delete
56    */
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();
60   }
61
62 }