function QueryTest::testReturnOptionDeprecation

Tests deprecation of the 'return' query option.

@covers ::query
@covers ::prepareStatement

@group legacy

File

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

Class

QueryTest
Tests Drupal's extended prepared statement syntax..

Namespace

Drupal\KernelTests\Core\Database

Code

public function testReturnOptionDeprecation() : void {
  $this->expectDeprecation('Passing "return" option to %Aquery() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520');
  $this->expectDeprecation('Passing "return" option to %AprepareStatement() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520');
  $this->assertIsInt((int) $this->connection
    ->query('INSERT INTO {test} ([name], [age], [job]) VALUES (:name, :age, :job)', [
    ':name' => 'Magoo',
    ':age' => 56,
    ':job' => 'Driver',
  ], [
    'return' => Database::RETURN_INSERT_ID,
  ]));
}

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