function SettingsTest::testGetInstanceReflection

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Site/SettingsTest.php \Drupal\Tests\Core\Site\SettingsTest::testGetInstanceReflection()
  2. 8.9.x core/tests/Drupal/Tests/Core/Site/SettingsTest.php \Drupal\Tests\Core\Site\SettingsTest::testGetInstanceReflection()
  3. 11.x core/tests/Drupal/Tests/Core/Site/SettingsTest.php \Drupal\Tests\Core\Site\SettingsTest::testGetInstanceReflection()

Tests that an exception is thrown when settings are not initialized yet.

@covers ::getInstance

File

core/tests/Drupal/Tests/Core/Site/SettingsTest.php, line 146

Class

SettingsTest
@coversDefaultClass \Drupal\Core\Site\Settings @runTestsInSeparateProcesses @group Site

Namespace

Drupal\Tests\Core\Site

Code

public function testGetInstanceReflection() : void {
    $settings = new Settings([]);
    $class = new \ReflectionClass(Settings::class);
    $instance_property = $class->getProperty("instance");
    $instance_property->setValue(NULL, NULL);
    $this->expectException(\BadMethodCallException::class);
    $settings->getInstance();
}

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