1. 8.5.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
  2. 8.0.x core/modules/system/src/Tests/Database/CaseSensitivityTest.php
  3. 8.1.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
  4. 8.2.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
  5. 8.3.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
  6. 8.4.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
  7. 8.6.x core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php

Namespace

Drupal\KernelTests\Core\Database

File

core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
View source
<?php

namespace Drupal\KernelTests\Core\Database;


/**
 * Tests handling case sensitive collation.
 *
 * @group Database
 */
class CaseSensitivityTest extends DatabaseTestBase {

  /**
   * Tests BINARY collation in MySQL.
   */
  function testCaseSensitiveInsert() {
    $num_records_before = db_query('SELECT COUNT(*) FROM {test}')
      ->fetchField();
    db_insert('test')
      ->fields(array(
      'name' => 'john',
      // <- A record already exists with name 'John'.
      'age' => 2,
      'job' => 'Baby',
    ))
      ->execute();
    $num_records_after = db_query('SELECT COUNT(*) FROM {test}')
      ->fetchField();
    $this
      ->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.');
    $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(
      ':name' => 'john',
    ))
      ->fetchField();
    $this
      ->assertIdentical($saved_age, '2', 'Can retrieve after inserting.');
  }

}

Classes

Namesort descending Description
CaseSensitivityTest Tests handling case sensitive collation.