You are here

function TaggingTest::testMetaData in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Database/TaggingTest.php \Drupal\system\Tests\Database\TaggingTest::testMetaData()

Tests that we can attach metadata to a query object.

This is how we pass additional context to alter hooks.

File

core/modules/system/src/Tests/Database/TaggingTest.php, line 114
Contains \Drupal\system\Tests\Database\TaggingTest.

Class

TaggingTest
Tests the tagging capabilities of the Select builder.

Namespace

Drupal\system\Tests\Database

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, 'Correct metadata returned.');
  $return = $query
    ->getMetaData('nothere');
  $this
    ->assertNull($return, 'Non-existent key returned NULL.');
}