function DrupalKernelTest::testPreventChangeOfSitePath

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::testPreventChangeOfSitePath()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::testPreventChangeOfSitePath()
  3. 11.x core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::testPreventChangeOfSitePath()

Tests setting of site path after kernel boot.

File

core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php, line 168

Class

DrupalKernelTest
Tests DIC compilation to disk.

Namespace

Drupal\KernelTests\Core\DrupalKernel

Code

public function testPreventChangeOfSitePath() : void {
    // @todo Write a memory based storage backend for testing.
    $modules_enabled = [
        'system' => 'system',
        'user' => 'user',
    ];
    $request = Request::createFromGlobals();
    $kernel = $this->getTestKernel($request, $modules_enabled);
    $pass = FALSE;
    try {
        $kernel->setSitePath('/dev/null');
    } catch (\LogicException $e) {
        $pass = TRUE;
    }
    $this->assertTrue($pass, 'Throws LogicException if DrupalKernel::setSitePath() is called after boot');
    // Ensure no LogicException if DrupalKernel::setSitePath() is called with
    // identical path after boot.
    $path = $kernel->getSitePath();
    $kernel->setSitePath($path);
}

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