UpdateCacheTest.php

Same filename in other branches
  1. 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php
  2. 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php
  3. 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php

Namespace

Drupal\Tests\system\Functional\UpdateSystem

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdateCacheTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\system\Functional\UpdateSystem;

use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\RequirementsPageTrait;

/**
 * Tests caches during updates.
 *
 * @group Update
 */
class UpdateCacheTest extends BrowserTestBase {
    use RequirementsPageTrait;
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests that caches are cleared during updates.
     *
     * @see \Drupal\Core\Update\UpdateServiceProvider
     * @see \Drupal\Core\Update\UpdateBackend
     */
    public function testCaches() : void {
        \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));
    }

}

Classes

Title Deprecated Summary
UpdateCacheTest Tests caches during updates.

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