Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ServiceLocatorTestCase.php

function ServiceLocatorTestCase::testThrowsOnUndefinedInternalService

File

vendor/symfony/service-contracts/Test/ServiceLocatorTestCase.php, line 69

Class

ServiceLocatorTestCase

Namespace

Symfony\Contracts\Service\Test

Code

public function testThrowsOnUndefinedInternalService() {
    $locator = $this->getServiceLocator([
        'foo' => function () use (&$locator) {
            return $locator->get('bar');
        },
    ]);
    if (!$this->getExpectedException()) {
        $this->expectException(NotFoundExceptionInterface::class);
        $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
    }
    $locator->get('foo');
}
RSS feed
Powered by Drupal