function ReadOnlyStorageTest::testWriteOperations

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/ReadOnlyStorageTest.php \Drupal\Tests\Core\Config\ReadOnlyStorageTest::testWriteOperations()
  2. 8.9.x 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 96

Class

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

Namespace

Drupal\Tests\Core\Config

Code

public function testWriteOperations($method, $arguments, $fixture) : void {
    $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.