function BasicSyntaxTest::testConcatLiterals

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php \Drupal\KernelTests\Core\Database\BasicSyntaxTest::testConcatLiterals()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php \Drupal\KernelTests\Core\Database\BasicSyntaxTest::testConcatLiterals()
  3. 10 core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php \Drupal\KernelTests\Core\Database\BasicSyntaxTest::testConcatLiterals()

Tests string concatenation.

File

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

Class

BasicSyntaxTest
Tests SQL syntax interpretation.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testConcatLiterals() : void {
    $result = $this->connection
        ->query('SELECT CONCAT(:a1, CONCAT(:a2, CONCAT(:a3, CONCAT(:a4, :a5))))', [
        ':a1' => 'This',
        ':a2' => ' ',
        ':a3' => 'is',
        ':a4' => ' a ',
        ':a5' => 'test.',
    ]);
    $this->assertSame('This is a test.', $result->fetchField(), 'Basic CONCAT works.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.