function ZfExtensionManagerSfContainerTest::testGet

Same name and namespace in other branches
  1. 9 core/modules/aggregator/tests/src/Unit/ZfExtensionManagerSfContainerTest.php \Drupal\Tests\aggregator\Unit\ZfExtensionManagerSfContainerTest::testGet()
  2. 9 core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php \Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest::testGet()

@covers ::setContainer @covers ::setStandalone @covers ::get

File

core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php, line 23

Class

ZfExtensionManagerSfContainerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Bridge%21ZfExtensionManagerSfContainer.php/class/ZfExtensionManagerSfContainer/8.9.x" title="Defines a bridge between the Laminas service manager to Symfony container." class="local">\Drupal\Component\Bridge\ZfExtensionManagerSfContainer</a> @group Bridge

Namespace

Drupal\Tests\Component\Bridge

Code

public function testGet() {
    $service = new \stdClass();
    $service->value = 'myvalue';
    $container = new ContainerBuilder();
    $container->set('foo', $service);
    $bridge = new ZfExtensionManagerSfContainer();
    $bridge->setContainer($container);
    $this->assertEquals($service, $bridge->get('foo'));
    $bridge->setStandalone(StandaloneExtensionManager::class);
    $this->assertInstanceOf(Entry::class, $bridge->get('Atom\\Entry'));
    // Ensure that the container is checked first.
    $container->set('atomentry', $service);
    $this->assertEquals($service, $bridge->get('Atom\\Entry'));
}

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