You are here

function UpdateComplexTest::testNotInConditionUpdate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/UpdateComplexTest.php \Drupal\system\Tests\Database\UpdateComplexTest::testNotInConditionUpdate()

Tests WHERE NOT IN clauses.

File

core/modules/system/src/Tests/Database/UpdateComplexTest.php, line 51
Contains \Drupal\system\Tests\Database\UpdateComplexTest.

Class

UpdateComplexTest
Tests the Update query builder, complex queries.

Namespace

Drupal\system\Tests\Database

Code

function testNotInConditionUpdate() {

  // The o is lowercase in the 'NoT IN' operator, to make sure the operators
  // work in mixed case.
  $num_updated = db_update('test')
    ->fields(array(
    'job' => 'Musician',
  ))
    ->condition('name', array(
    'John',
    'Paul',
    'George',
  ), 'NoT IN')
    ->execute();
  $this
    ->assertIdentical($num_updated, 1, 'Updated 1 record.');
  $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(
    ':job' => 'Musician',
  ))
    ->fetchField();
  $this
    ->assertIdentical($num_matches, '1', 'Updated fields successfully.');
}