1. 8.3.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.4.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
  1. <?php
  2. namespace Drupal\KernelTests\Core\Database;
  3. /**
  4. * Tests handling case sensitive collation.
  5. *
  6. * @group Database
  7. */
  8. class CaseSensitivityTest extends DatabaseTestBase {
  9. /**
  10. * Tests BINARY collation in MySQL.
  11. */
  12. function testCaseSensitiveInsert() {
  13. $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
  14. db_insert('test')
  15. ->fields(array(
  16. 'name' => 'john', // <- A record already exists with name 'John'.
  17. 'age' => 2,
  18. 'job' => 'Baby',
  19. ))
  20. ->execute();
  21. $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
  22. $this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.');
  23. $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'john'))->fetchField();
  24. $this->assertIdentical($saved_age, '2', 'Can retrieve after inserting.');
  25. }
  26. }

Classes

Namesort descending Description
CaseSensitivityTest Tests handling case sensitive collation.