You are here

public function UpdateComplexTest::testBetweenConditionUpdate in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php \Drupal\KernelTests\Core\Database\UpdateComplexTest::testBetweenConditionUpdate()

Tests BETWEEN conditional clauses.

File

core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php, line 64

Class

UpdateComplexTest
Tests the Update query builder, complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testBetweenConditionUpdate() {
  $num_updated = $this->connection
    ->update('test')
    ->fields([
    'job' => 'Musician',
  ])
    ->condition('age', [
    25,
    26,
  ], 'BETWEEN')
    ->execute();
  $this
    ->assertIdentical($num_updated, 2, 'Updated 2 records.');
  $num_matches = $this->connection
    ->query('SELECT COUNT(*) FROM {test} WHERE job = :job', [
    ':job' => 'Musician',
  ])
    ->fetchField();
  $this
    ->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}