You are here

public function ConfigStorageTestBase::testDataTypes in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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);
}