You are here

public function HttpClientManagerFactoryTest::testGet in HTTP Client Manager 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/HttpClientManagerFactoryTest.php \Drupal\Tests\http_client_manager\Unit\HttpClientManagerFactoryTest::testGet()

Tests HttpClientManagerFactory::get().

@covers ::get

File

tests/src/Unit/HttpClientManagerFactoryTest.php, line 26

Class

HttpClientManagerFactoryTest
Class HttpClientManagerFactoryTest.

Namespace

Drupal\Tests\http_client_manager\Unit

Code

public function testGet() {
  $factory = new HttpClientManagerFactory();
  $container = new ContainerBuilder();
  $apiHandler = $this
    ->prophesize(HttpServiceApiHandlerInterface::class);
  $apiHandler
    ->load(Argument::any())
    ->will(function ($args) {
    return $args;
  });
  $container
    ->set('http_client_manager.http_services_api', $apiHandler
    ->reveal());
  $event_dispatcher = $this
    ->prophesize(EventDispatcherInterface::class);
  $container
    ->set('event_dispatcher', $event_dispatcher
    ->reveal());
  $factory
    ->setContainer($container);

  // Ensure that when called with the same argument, always the same instance
  // will be returned.
  $this
    ->assertSame($factory
    ->get('test'), $factory
    ->get('test'));
}