function ReadOnlyStorageTest::testWriteOperations

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::testWriteOperations()
  2. 10 core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::testWriteOperations()
  3. 11.x core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::testWriteOperations()

@covers ::write @covers ::delete @covers ::rename @covers ::deleteAll

@dataProvider writeMethodsProvider

File

core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php, line 91

Class

ReadOnlyStorageTest
@coversDefaultClass \Drupal\Core\Config\ReadOnlyStorage @group Config

Namespace

Drupal\Tests\Core\Config

Code

public function testWriteOperations($method, $arguments, $fixture) {
    $this->setRandomFixtureConfig($fixture);
    // Create an independent memory storage as a backup.
    $backup = new MemoryStorage();
    static::replaceStorageContents($this->memory, $backup);
    try {
        call_user_func_array([
            $this->storage,
            $method,
        ], $arguments);
        $this->fail("exception not thrown");
    } catch (\BadMethodCallException $exception) {
        $this->assertEquals(ReadOnlyStorage::class . '::' . $method . ' is not allowed on a ReadOnlyStorage', $exception->getMessage());
    }
    // Assert that the memory storage has not been altered.
    $this->assertEquals($backup, $this->memory);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.