function DrupalTest::testGetContainerException

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testGetContainerException()
  2. 8.9.x core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testGetContainerException()
  3. 10 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testGetContainerException()

@covers ::getContainer

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 54

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

public function testGetContainerException() : void {
    $this->expectException(ContainerNotInitializedException::class);
    $this->expectExceptionMessage('\\Drupal::$container is not initialized yet. \\Drupal::setContainer() must be called with a real container.');
    \Drupal::getContainer();
}

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