You are here

protected function NoPreExistingSchemaUpdateTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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 23

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();
}