You are here

function DatabaseTaggingTestCase::testMetaData in Drupal 7

Test that we can attach meta data to a query object.

This is how we pass additional context to alter hooks.

File

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

Class

DatabaseTaggingTestCase
Select tagging tests.

Code

function testMetaData() {
  $query = db_select('test');
  $query
    ->addField('test', 'name');
  $query
    ->addField('test', 'age', 'age');
  $data = array(
    'a' => 'A',
    'b' => 'B',
  );
  $query
    ->addMetaData('test', $data);
  $return = $query
    ->getMetaData('test');
  $this
    ->assertEqual($data, $return, 'Corect metadata returned.');
  $return = $query
    ->getMetaData('nothere');
  $this
    ->assertNull($return, 'Non-existent key returned NULL.');
}