function UpdatePostUpdateExceptionTest::setUp

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateExceptionTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateExceptionTest::setUp()
  2. 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateExceptionTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePostUpdateExceptionTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateExceptionTest.php, line 27

Class

UpdatePostUpdateExceptionTest
Tests hook_post_update() when there is an exception in a post update.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

protected function setUp() : void {
    parent::setUp();
    $connection = Database::getConnection();
    // Set the schema version.
    \Drupal::service('update.update_hook_registry')->setInstalledVersion('post_update_test_failing', 8000);
    // Update core.extension.
    $extensions = $connection->select('config')
        ->fields('config', [
        'data',
    ])
        ->condition('collection', '')
        ->condition('name', 'core.extension')
        ->execute()
        ->fetchField();
    $extensions = unserialize($extensions);
    $extensions['module']['post_update_test_failing'] = 8000;
    $connection->update('config')
        ->fields([
        'data' => serialize($extensions),
    ])
        ->condition('collection', '')
        ->condition('name', 'core.extension')
        ->execute();
}

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