You are here

function DatabaseUpdateComplexTestCase::testInConditionUpdate in SimpleTest 7

Test WHERE IN clauses.

File

tests/database_test.test, line 777

Class

DatabaseUpdateComplexTestCase
Tests for more complex update statements.

Code

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