You are here

public function ContainerBuilderTest::testSetException in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php \Drupal\Tests\Core\DependencyInjection\ContainerBuilderTest::testSetException()

@covers ::set

File

core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php, line 40

Class

ContainerBuilderTest
@coversDefaultClass \Drupal\Core\DependencyInjection\ContainerBuilder @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection

Code

public function testSetException() {
  $container = new ContainerBuilder();
  $class = new BarClass();
  $this
    ->expectException(\InvalidArgumentException::class);
  $this
    ->expectExceptionMessage('Service ID names must be lowercase: Bar');
  $container
    ->set('Bar', $class);
}