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

Tests numeric query parameter expansion in expressions.

See also

\Drupal\sqlite\Driver\Database\sqlite\Statement::getStatement()

http://bugs.php.net/bug.php?id=45259

File

core/tests/Drupal/KernelTests/Core/Database/QueryTest.php, line 149

Class

QueryTest
Tests Drupal's extended prepared statement syntax..

Namespace

Drupal\KernelTests\Core\Database

Code

public function testNumericExpressionSubstitution() {
  $count_expected = $this->connection
    ->query('SELECT COUNT(*) + 3 FROM {test}')
    ->fetchField();
  $count = $this->connection
    ->query('SELECT COUNT(*) + :count FROM {test}', [
    ':count' => 3,
  ])
    ->fetchField();
  $this
    ->assertEquals($count_expected, $count);
}