function ConfigStorageTestBase::testDataTypes

Tests storage writing and reading data preserving data type.

File

core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php, line 161

Class

ConfigStorageTestBase
Base class for testing storage operations.

Namespace

Drupal\KernelTests\Core\Config\Storage

Code

public function testDataTypes() {
  $name = 'config_test.types';
  $data = [
    'array' => [],
    'boolean' => TRUE,
    'exp' => 1.2E+34,
    'float' => 3.14159,
    'hex' => 0xc,
    'int' => 99,
    'octal' => 0775,
    'string' => 'string',
    'string_int' => '1',
  ];
  $result = $this->storage
    ->write($name, $data);
  $this->assertIdentical($result, TRUE);
  $read_data = $this->storage
    ->read($name);
  $this->assertIdentical($read_data, $data);
}

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