You are here

function DatabaseMergeTestCase::testInvalidMerge in Drupal 7

Test that an invalid merge query throws an exception like it is supposed to.

File

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

Class

DatabaseMergeTestCase
Test the MERGE query builder.

Code

function testInvalidMerge() {
  try {

    // This query should die because there is no key field specified.
    db_merge('test_people')
      ->fields(array(
      'age' => 31,
      'name' => 'Tiffany',
    ))
      ->execute();
  } catch (InvalidMergeQueryException $e) {
    $this
      ->pass('InvalidMergeQueryException thrown for invalid query.');
    return;
  }
  $this
    ->fail('No InvalidMergeQueryException thrown');
}