You are here

protected function BrowserTestBase::getHttpClient in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getHttpClient()

Obtain the HTTP client for the system under test.

Use this method for arbitrary HTTP requests to the site under test. For most tests, you should not get the HTTP client and instead use navigation methods such as drupalGet() and clickLink() in order to benefit from assertions.

Subclasses which substitute a different Mink driver should override this method and provide a Guzzle client if the Mink driver provides one.

Return value

\GuzzleHttp\ClientInterface The client with BrowserTestBase configuration.

Throws

\RuntimeException If the Mink driver does not support a Guzzle HTTP client, throw an exception.

18 calls to BrowserTestBase::getHttpClient()
CommentNewIndicatorTest::renderNewCommentsNodeLinks in core/modules/comment/tests/src/Functional/CommentNewIndicatorTest.php
Get node "x new comments" metadata from the server for the current user.
ContextualDynamicContextTest::renderContextualLinks in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
Get server-rendered contextual links for the given contextual link ids.
ContextualDynamicContextTest::testTokenProtection in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
Tests the contextual placeholder content is protected by a token.
CsrfRequestHeaderTest::testRouteAccess in core/modules/system/tests/src/Functional/CsrfRequestHeaderTest.php
Tests access to routes protected by CSRF request header requirements.
DestinationTest::testDestination in core/modules/system/tests/src/Functional/Routing/DestinationTest.php
Tests that $_GET/$_REQUEST['destination'] only contain internal URLs.

... See full list

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 533

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

protected function getHttpClient() {

  /* @var $mink_driver \Behat\Mink\Driver\DriverInterface */
  $mink_driver = $this
    ->getSession()
    ->getDriver();
  if ($mink_driver instanceof GoutteDriver) {
    return $mink_driver
      ->getClient()
      ->getClient();
  }
  throw new \RuntimeException('The Mink client type ' . get_class($mink_driver) . ' does not support getHttpClient().');
}