function NoPreExistingSchemaUpdateTest::setUp

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

Overrides BrowserTestBase::setUp

File

core/modules/system/tests/src/Functional/UpdateSystem/NoPreExistingSchemaUpdateTest.php, line 28

Class

NoPreExistingSchemaUpdateTest
Tries to update a module which has no pre-existing schema.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

protected function setUp() : void {
    parent::setUp();
    $connection = Database::getConnection();
    // Enable the update_test_no_preexisting module by altering the
    // core.extension configuration directly, so that the schema version
    // information is missing.
    $extensions = $connection->select('config')
        ->fields('config', [
        'data',
    ])
        ->condition('name', 'core.extension')
        ->execute()
        ->fetchField();
    $extensions = unserialize($extensions);
    $connection->update('config')
        ->fields([
        'data' => serialize(array_merge_recursive($extensions, [
            'module' => [
                'update_test_no_preexisting' => 0,
            ],
        ])),
    ])
        ->condition('name', 'core.extension')
        ->execute();
}

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