function Y2038TimestampUpdateTest::testUpdate

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php \Drupal\Tests\system\Functional\Update\Y2038TimestampUpdateTest::testUpdate()

Tests update of time fields.

File

core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php, line 95

Class

Y2038TimestampUpdateTest
Tests update of timestamp fields to bigint.

Namespace

Drupal\Tests\system\Functional\Update

Code

public function testUpdate() {
    if (\Drupal::service('database')->databaseType() == 'sqlite') {
        $this->markTestSkipped("This test does not support the SQLite database driver.");
    }
    // Create a table starting with cache that is not a cache bin.
    \Drupal::service('database')->schema()
        ->createTable('cache_bogus', [
        'fields' => [
            'id' => [
                'type' => 'int',
                'not null' => TRUE,
            ],
        ],
        'primary key' => [
            'id',
        ],
    ]);
    $this->collectTimestampFieldsFromDatabase();
    // PostgreSQL returns the value 'integer' instead of 'int' when queried
    // about the column type. Some PostgreSQL tables are already of the type
    // 'bigint'.
    $this->assertTimestampFields([
        'int',
        'integer',
        'bigint',
    ]);
    $this->runUpdates();
    $this->assertTimestampFields([
        'bigint',
    ]);
}

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