function BrowserTestBase::getHttpClient
Same name in other branches
- 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getHttpClient()
- 8.9.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getHttpClient()
- 11.x 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.
14 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.
File
-
core/
tests/ Drupal/ Tests/ BrowserTestBase.php, line 530
Class
- BrowserTestBase
- Provides a test case for functional Drupal tests.
Namespace
Drupal\TestsCode
protected function getHttpClient() {
/** @var \Behat\Mink\Driver\DriverInterface $mink_driver */
$mink_driver = $this->getSession()
->getDriver();
if ($this->isTestUsingGuzzleClient()) {
return $mink_driver->getClient()
->getClient();
}
throw new \RuntimeException('The Mink client type ' . get_class($mink_driver) . ' does not support getHttpClient().');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.