function DatabaseLegacyTest::testDbChangeField

Tests the db_change_field() function is deprecated.

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

File

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

Class

DatabaseLegacyTest
Deprecation tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDbChangeField() {
    $spec = [
        'description' => "A new person's name",
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'binary' => TRUE,
    ];
    db_change_field('test', 'name', 'nosuchcolumn', $spec);
}

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