function NoPreExistingSchemaUpdateTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/UpdateSystem/NoPreExistingSchemaUpdateTest.php \Drupal\Tests\system\Functional\UpdateSystem\NoPreExistingSchemaUpdateTest::setUp()
  2. 10 core/modules/system/tests/src/Functional/UpdateSystem/NoPreExistingSchemaUpdateTest.php \Drupal\Tests\system\Functional\UpdateSystem\NoPreExistingSchemaUpdateTest::setUp()
  3. 11.x 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 19

Class

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

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

protected function setUp() {
    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.