function ConfigStorageTestBase::testDataTypes

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase::testDataTypes()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase::testDataTypes()
  3. 11.x core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\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->assertTrue($result);
    $read_data = $this->storage
        ->read($name);
    $this->assertSame($data, $read_data);
}

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