1 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

core/modules/simpletest/tests/database_test.test, line 2577
Database tests.

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