You are here

public function ReservedWordTest::testSelectReservedWordAliasSpecificFields in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php \Drupal\KernelTests\Core\Database\ReservedWordTest::testSelectReservedWordAliasSpecificFields()

Tests SELECT query with specific fields from a table with a reserved alias.

File

core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php, line 57

Class

ReservedWordTest
Tests queries that include reserved words.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSelectReservedWordAliasSpecificFields() {
  $query = $this->connection
    ->select('test', 'high_priority');
  $query
    ->addField('high_priority', 'name');
  $query
    ->addField('high_priority', 'age', 'age');
  $query
    ->condition('age', 27);
  $record = $query
    ->execute()
    ->fetchObject();

  // Ensure that we got the right record.
  $this
    ->assertSame('George', $record->name);
  $this
    ->assertSame('27', $record->age);
}