public function TaggingTest::testMetaData in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php \Drupal\KernelTests\Core\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/
tests/ Drupal/ KernelTests/ Core/ Database/ TaggingTest.php, line 109
Class
- TaggingTest
- Tests the tagging capabilities of the Select builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testMetaData() {
$query = $this->connection
->select('test');
$query
->addField('test', 'name');
$query
->addField('test', 'age', 'age');
$data = [
'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.');
}