function UpdateComplexTest::testLikeConditionUpdate

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php \Drupal\KernelTests\Core\Database\UpdateComplexTest::testLikeConditionUpdate()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php \Drupal\KernelTests\Core\Database\UpdateComplexTest::testLikeConditionUpdate()
  3. 11.x 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 78

Class

UpdateComplexTest
Tests the Update query builder, complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testLikeConditionUpdate() {
    $num_updated = $this->connection
        ->update('test')
        ->fields([
        'job' => 'Musician',
    ])
        ->condition('name', '%ge%', 'LIKE')
        ->execute();
    $this->assertIdentical($num_updated, 1, 'Updated 1 record.');
    $num_matches = $this->connection
        ->query('SELECT COUNT(*) FROM {test} WHERE job = :job', [
        ':job' => 'Musician',
    ])
        ->fetchField();
    $this->assertIdentical($num_matches, '1', 'Updated fields successfully.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.