You are here

public function UpdateCacheTest::testCaches in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateCacheTest::testCaches()
  2. 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateCacheTest::testCaches()

Tests that caches are cleared during updates.

See also

\Drupal\Core\Update\UpdateServiceProvider

\Drupal\Core\Update\UpdateBackend

File

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

Class

UpdateCacheTest
Tests caches during updates.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testCaches() {
  \Drupal::cache()
    ->set('will_not_exist_after_update', TRUE);

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

  // Clicking continue should clear the caches.
  $this
    ->drupalGet(Url::fromRoute('system.db_update', [], [
    'path_processing' => FALSE,
  ]));
  $this
    ->updateRequirementsProblem();
  $this
    ->clickLink('Continue');
  $this
    ->assertFalse(\Drupal::cache()
    ->get('will_not_exist_after_update', FALSE));
}