function ReadOnlyStorageTest::testEncodeDecode

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

@covers ::encode @covers ::decode

File

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

Class

ReadOnlyStorageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21ReadOnlyStorage.php/class/ReadOnlyStorage/9" title="A ReadOnlyStorage decorates a storage and does not allow writing to it." class="local">\Drupal\Core\Config\ReadOnlyStorage</a> @group Config

Namespace

Drupal\Tests\Core\Config

Code

public function testEncodeDecode() {
    $array = (array) $this->getRandomGenerator()
        ->object();
    $string = $this->getRandomGenerator()
        ->string();
    // Assert reversibility of encoding and decoding.
    $this->assertEquals($array, $this->storage
        ->decode($this->storage
        ->encode($array)));
    $this->assertEquals($string, $this->storage
        ->encode($this->storage
        ->decode($string)));
    // Assert same results as the decorated storage.
    $this->assertEquals($this->memory
        ->encode($array), $this->storage
        ->encode($array));
    $this->assertEquals($this->memory
        ->decode($string), $this->storage
        ->decode($string));
}

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