You are here

public function RebuildScriptTest::testRebuild in Drupal 8

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

Test redirect in rebuild.php.

File

core/modules/system/tests/src/Functional/UpdateSystem/RebuildScriptTest.php, line 23

Class

RebuildScriptTest
Tests the rebuild script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testRebuild() {
  $cache = $this->container
    ->get('cache.default');
  $cache
    ->set('rebuild_test', TRUE);
  $this
    ->drupalGet(Url::fromUri('base:core/rebuild.php'));
  $this
    ->assertUrl(new Url('<front>'));
  $this
    ->assertInstanceOf(\stdClass::class, $cache
    ->get('rebuild_test'));
  $settings['settings']['rebuild_access'] = (object) [
    'value' => TRUE,
    'required' => TRUE,
  ];
  $this
    ->writeSettings($settings);
  $this
    ->rebuildAll();
  $cache
    ->set('rebuild_test', TRUE);
  $this
    ->drupalGet(Url::fromUri('base:core/rebuild.php'));
  $this
    ->assertUrl(new Url('<front>'));
  $this
    ->assertFalse($cache
    ->get('rebuild_test'));
}