You are here

protected function UpdatePathTestBase::runUpdates in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Update/UpdatePathTestBase.php \Drupal\system\Tests\Update\UpdatePathTestBase::runUpdates()

Helper function to run pending database updates.

32 calls to UpdatePathTestBase::runUpdates()
ArgumentPlaceholderUpdatePathTest::testArgumentPlaceholderUpdate in core/modules/views/src/Tests/Update/ArgumentPlaceholderUpdatePathTest.php
Ensures that %1 and !1 are converted to twig tokens in existing views.
AutomatedCronUpdateWithAutomatedCronTest::testUpdate in core/modules/system/src/Tests/Update/AutomatedCronUpdateWithAutomatedCronTest.php
Ensures that automated cron module isn installed and the config migrated.
AutomatedCronUpdateWithoutAutomatedCronTest::testUpdate in core/modules/system/src/Tests/Update/AutomatedCronUpdateWithoutAutomatedCronTest.php
Ensures that automated cron module isn't installed and the config migrated.
BlockContextMappingUpdateTest::testUpdateHookN in core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php
Tests that block context mapping is updated properly.
CacheabilityMetadataUpdateTest::testUpdateHookN in core/modules/views/src/Tests/Update/CacheabilityMetadataUpdateTest.php
Tests that views cacheability metadata updated properly.

... See full list

File

core/modules/system/src/Tests/Update/UpdatePathTestBase.php, line 236
Contains \Drupal\system\Tests\Update\UpdatePathTestBase.

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\system\Tests\Update

Code

protected function runUpdates() {
  if (!$this->zlibInstalled) {
    $this
      ->fail('Missing zlib requirement for update tests.');
    return FALSE;
  }

  // The site might be broken at the time so logging in using the UI might
  // not work, so we use the API itself.
  drupal_rewrite_settings([
    'settings' => [
      'update_free_access' => (object) [
        'value' => TRUE,
        'required' => TRUE,
      ],
    ],
  ]);
  $this
    ->drupalGet($this->updateUrl);
  $this
    ->clickLink(t('Continue'));
  $this
    ->doSelectionTest();

  // Run the update hooks.
  $this
    ->clickLink(t('Apply pending updates'));

  // Ensure there are no failed updates.
  if ($this->checkFailedUpdates) {
    $this
      ->assertNoRaw('<strong>' . t('Failed:') . '</strong>');
  }

  // The config schema can be incorrect while the update functions are being
  // executed. But once the update has been completed, it needs to be valid
  // again. Assert the schema of all configuration objects now.
  $names = $this->container
    ->get('config.storage')
    ->listAll();

  /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
  $typed_config = $this->container
    ->get('config.typed');
  $typed_config
    ->clearCachedDefinitions();
  foreach ($names as $name) {
    $config = $this
      ->config($name);
    $this
      ->assertConfigSchema($typed_config, $name, $config
      ->get());
  }

  // Ensure that the update hooks updated all entity schema.
  $this
    ->assertFalse(\Drupal::service('entity.definition_update_manager')
    ->needsUpdates(), 'After all updates ran, entity schema is up to date.');
}