You are here

public function DatabaseLegacyTest::testDbDropField in Drupal 8

Tests deprecation of the db_drop_field() function.

@expectedDeprecation db_drop_field() 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 dropField() on it. For example, $injected_database->schema()->dropField($table, $field). See https://www.drupal.org/node/2993033

File

core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php, line 252

Class

DatabaseLegacyTest
Deprecation tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDbDropField() {
  $this
    ->assertTrue($this->connection
    ->schema()
    ->fieldExists('test', 'age'));
  $this
    ->assertTrue(db_drop_field('test', 'age'));
  $this
    ->assertFalse($this->connection
    ->schema()
    ->fieldExists('test', 'age'));
}