function ConnectionTest::testConnectionWithIntegerKeyAndTarget

Tests deprecation of integer values for connection $key and $target.

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php, line 59

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testConnectionWithIntegerKeyAndTarget() : void {
  $this->expectUserDeprecationMessage('Passing an integer value to the $target parameter in Drupal\\Core\\Database\\Database::addConnectionInfo() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $key parameter in Drupal\\Core\\Database\\Database::addConnectionInfo() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $target parameter in Drupal\\Core\\Database\\Database::getConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $target parameter in Drupal\\Core\\Database\\Database::openConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $key parameter in Drupal\\Core\\Database\\Database::getConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $key parameter in Drupal\\Core\\Database\\Database::openConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $target parameter in Drupal\\Core\\Database\\Database::closeConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $this->expectUserDeprecationMessage('Passing an integer value to the $key parameter in Drupal\\Core\\Database\\Database::closeConnection() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925');
  $connection_info = Database::getConnectionInfo('default');
  Database::addConnectionInfo('default', 200, $connection_info['default']);
  Database::addConnectionInfo(100, 300, $connection_info['default']);
  $db1 = Database::getConnection('default', 'default');
  $db2 = Database::getConnection(200, 'default');
  $db3 = Database::getConnection(300, 100);
  $this->assertNotNull($db1);
  $this->assertNotNull($db2);
  $this->assertNotNull($db3);
  Database::closeConnection(300, 100);
}

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