function DatabaseTaggingTestCase::testMetaData

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 2897

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.