You are here

function DatabaseUpdateComplexTestCase::testOrConditionUpdate in Drupal 7

Test updates with OR conditionals.

File

modules/simpletest/tests/database_test.test, line 911

Class

DatabaseUpdateComplexTestCase
Tests for more complex update statements.

Code

function testOrConditionUpdate() {
  $update = db_update('test')
    ->fields(array(
    'job' => 'Musician',
  ))
    ->condition(db_or()
    ->condition('name', 'John')
    ->condition('name', 'Paul'));
  $num_updated = $update
    ->execute();
  $this
    ->assertIdentical($num_updated, 2, 'Updated 2 records.');
  $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(
    ':job' => 'Musician',
  ))
    ->fetchField();
  $this
    ->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}