public function DatabaseLegacyTest::testDbAddPrimaryKey in Drupal 8
Tests deprecation of the db_add_primary_key() function.
@expectedDeprecation db_add_primary_key() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call addPrimaryKey() on it. For example, $injected_database->schema()->addPrimaryKey($table, $fields). See https://www.drupal.org/node/2993033 @doesNotPerformAssertions
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php, line 405
Class
- DatabaseLegacyTest
- Deprecation tests cases for the database layer.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testDbAddPrimaryKey() {
$this->connection
->schema()
->dropPrimaryKey('test_people');
db_add_primary_key('test_people', [
'job',
]);
}