function ZfExtensionManagerSfContainerTest::testGet

Same name in this branch
  1. 9 core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php \Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest::testGet()
Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php \Drupal\Tests\Component\Bridge\ZfExtensionManagerSfContainerTest::testGet()

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

File

core/modules/aggregator/tests/src/Unit/ZfExtensionManagerSfContainerTest.php, line 24

Class

ZfExtensionManagerSfContainerTest
@coversDefaultClass \Drupal\aggregator\ZfExtensionManagerSfContainer[[api-linebreak]] @group aggregator @group legacy

Namespace

Drupal\Tests\aggregator\Unit

Code

public function testGet() {
  $service = new \stdClass();
  $service->value = 'my_value';
  $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 standalone service is checked before the container.
  $container->set('atomentry', $service);
  $this->assertInstanceOf(Entry::class, $bridge->get('Atom\\Entry'));
}

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