You are here

public function ContainerTest::testInitialized in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testInitialized()
  2. 8 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testInitialized()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testInitialized()

@covers Symfony\Component\DependencyInjection\Container::initialized

File

vendor/symfony/dependency-injection/Tests/ContainerTest.php, line 301

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testInitialized() {
  $sc = new ProjectServiceContainer();
  $sc
    ->set('foo', new \stdClass());
  $this
    ->assertTrue($sc
    ->initialized('foo'), '->initialized() returns true if service is loaded');
  $this
    ->assertFalse($sc
    ->initialized('foo1'), '->initialized() returns false if service is not loaded');
  $this
    ->assertFalse($sc
    ->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
  $this
    ->assertFalse($sc
    ->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
  $sc
    ->set('bar', new \stdClass());
  $this
    ->assertTrue($sc
    ->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
}