You are here

function BasicSyntaxTest::testConcatFields in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/BasicSyntaxTest.php \Drupal\system\Tests\Database\BasicSyntaxTest::testConcatFields()

Tests string concatenation with field values.

File

core/modules/system/src/Tests/Database/BasicSyntaxTest.php, line 37
Contains \Drupal\system\Tests\Database\BasicSyntaxTest.

Class

BasicSyntaxTest
Tests SQL syntax interpretation.

Namespace

Drupal\system\Tests\Database

Code

function testConcatFields() {
  $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', array(
    ':a1' => 'The age of ',
    ':a2' => ' is ',
    ':a3' => '.',
    ':age' => 25,
  ));
  $this
    ->assertIdentical($result
    ->fetchField(), 'The age of John is 25.', 'Field CONCAT works.');
}