function DatabaseTaggingTestCase::testMetaData

7.x database_test.test DatabaseTaggingTestCase::testMetaData()

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

This is how we pass additional context to alter hooks.

File

drupal-7.x/modules/simpletest/tests/database_test.test, line 2629

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.');
}