You are here

public function BasicSyntaxTest::testConcatWsFields in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php \Drupal\KernelTests\Core\Database\BasicSyntaxTest::testConcatWsFields()

Tests string concatenation with separator, with field values.

File

core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php, line 66

Class

BasicSyntaxTest
Tests SQL syntax interpretation.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testConcatWsFields() {
  $result = $this->connection
    ->query("SELECT CONCAT_WS('-', :a1, [name], :a2, [age]) FROM {test} WHERE [age] = :age", [
    ':a1' => 'name',
    ':a2' => 'age',
    ':age' => 25,
  ]);
  $this
    ->assertSame('name-John-age-25', $result
    ->fetchField());
}