fromOptions example


  protected $httpClient;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Set up a HTTP client that accepts relative URLs.     $this->httpClient = $this->container->get('http_client_factory')
      ->fromOptions(['base_uri' => $this->baseUrl]);

    // Create Basic page and Article node types.     if ($this->profile != 'standard') {
      $this->drupalCreateContentType([
        'type' => 'article',
        'name' => 'Article',
      ]);

      // Setup vocabulary.       Vocabulary::create([
        'vid' => 'tags',
        
/** * Initializes Mink sessions. */
  protected function initMink() {
    $driver = $this->getDefaultDriverInstance();

    if ($driver instanceof BrowserKitDriver) {
      // Turn off curl timeout. Having a timeout is not a problem in a normal       // test running, but it is a problem when debugging. Also, disable SSL       // peer verification so that testing under HTTPS always works.       /** @var \GuzzleHttp\Client $client */
      $client = $this->container->get('http_client_factory')->fromOptions([
        'timeout' => NULL,
        'verify' => FALSE,
      ]);

      // Inject a Guzzle middleware to generate debug output for every request       // performed in the test.       $handler_stack = $client->getConfig('handler');
      $handler_stack->push($this->getResponseLogHandler());

      $driver->getClient()->setClient($client);
    }

    

  public function testCreateFromOptions($settings_config$parameter_config$expected_config_keys) {
    if ($settings_config) {
      new Settings(['http_client_config' => $settings_config]);
    }
    else {
      new Settings([]);
    }

    $client = $this->factory->fromOptions($parameter_config);

    foreach ($expected_config_keys as $key => $expected) {
      $this->assertSame($expected$client->getConfig($key));
    }
  }

  /** * Data provider for testCreateFromOptions. * * @return array */
  
Home | Imprint | This part of the site doesn't use cookies.