You are here

public function ReservedWordTest::testSelectReservedWordAliasAllFields 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::testSelectReservedWordAliasAllFields()

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

File

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

Class

ReservedWordTest
Tests queries that include reserved words.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSelectReservedWordAliasAllFields() {
  $record = $this->connection
    ->select('test', 'signal')
    ->fields('signal')
    ->condition('age', 27)
    ->execute()
    ->fetchObject();

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