function MenuTreeStorageSchemaUpdateTest::testSchemaLengthAfterUpdate

Tests DB behavior after update.

File

core/modules/system/tests/src/Functional/Update/MenuTreeStorageSchemaUpdateTest.php, line 46

Class

MenuTreeStorageSchemaUpdateTest
Tests update of menu tree storage fields.

Namespace

Drupal\Tests\system\Functional\Update

Code

public function testSchemaLengthAfterUpdate() : void {
    if (\Drupal::service('database')->databaseType() == 'sqlite') {
        $this->markTestSkipped("This test does not support the SQLite database driver.");
    }
    $results = $this->connection
        ->query('SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :menu AND COLUMN_NAME IN ( :column_names[] )', [
        ':menu' => $this->connection
            ->schema()
            ->prefixNonTable('menu_tree'),
        ':column_names[]' => [
            'route_param_key',
            'url',
        ],
    ])
        ->fetchCol();
    $this->assertNotEmpty($results);
    foreach ($results as $result) {
        self::assertEquals(255, $result);
    }
    $this->runUpdates();
    $results = $this->connection
        ->query('SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :menu AND COLUMN_NAME IN ( :column_names[] )', [
        ':menu' => $this->connection
            ->schema()
            ->prefixNonTable('menu_tree'),
        ':column_names[]' => [
            'route_param_key',
            'url',
        ],
    ])
        ->fetchCol();
    $this->assertNotEmpty($results);
    foreach ($results as $result) {
        self::assertEquals(2048, $result);
    }
}

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