function CheckpointStorageTest::testEncodeDecode

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php \Drupal\Tests\Core\Config\Checkpoint\CheckpointStorageTest::testEncodeDecode()

@covers ::encode @covers ::decode

File

core/tests/Drupal/Tests/Core/Config/Checkpoint/CheckpointStorageTest.php, line 263

Class

CheckpointStorageTest
@coversDefaultClass \Drupal\Core\Config\Checkpoint\CheckpointStorage @group Config

Namespace

Drupal\Tests\Core\Config\Checkpoint

Code

public function testEncodeDecode() : void {
    $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.