public function UpdateComplexTest::testLikeConditionUpdate in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php \Drupal\KernelTests\Core\Database\UpdateComplexTest::testLikeConditionUpdate()
Tests LIKE conditionals.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ UpdateComplexTest.php, line 76
Class
- UpdateComplexTest
- Tests the Update query builder, complex queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testLikeConditionUpdate() {
$num_updated = $this->connection
->update('test')
->fields([
'job' => 'Musician',
])
->condition('name', '%ge%', 'LIKE')
->execute();
$this
->assertSame(1, $num_updated, 'Updated 1 record.');
$num_matches = $this->connection
->query('SELECT COUNT(*) FROM {test} WHERE [job] = :job', [
':job' => 'Musician',
])
->fetchField();
$this
->assertSame('1', $num_matches, 'Updated fields successfully.');
}