class CaseSensitivityTest in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php \Drupal\KernelTests\Core\Database\CaseSensitivityTest
- 9 core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php \Drupal\KernelTests\Core\Database\CaseSensitivityTest
Tests handling case sensitive collation.
@group Database
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase
- class \Drupal\KernelTests\Core\Database\CaseSensitivityTest
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase
Expanded class hierarchy of CaseSensitivityTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ CaseSensitivityTest.php, line 10
Namespace
Drupal\KernelTests\Core\DatabaseView source
class CaseSensitivityTest extends DatabaseTestBase {
/**
* Tests BINARY collation in MySQL.
*/
public function testCaseSensitiveInsert() {
$num_records_before = $this->connection
->query('SELECT COUNT(*) FROM {test}')
->fetchField();
$this->connection
->insert('test')
->fields([
// A record already exists with name 'John'.
'name' => 'john',
'age' => 2,
'job' => 'Baby',
])
->execute();
$num_records_after = $this->connection
->query('SELECT COUNT(*) FROM {test}')
->fetchField();
$this
->assertSame($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.');
$saved_age = $this->connection
->query('SELECT [age] FROM {test} WHERE [name] = :name', [
':name' => 'john',
])
->fetchField();
$this
->assertSame('2', $saved_age, 'Can retrieve after inserting.');
}
}