function BrowserTestBase::getHttpClient
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getHttpClient()
- 10 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getHttpClient()
- 8.9.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.
3 calls to BrowserTestBase::getHttpClient()
- DownloadTest::doPrivateFileTransferTest in core/
modules/ file/ tests/ src/ Functional/ DownloadTest.php - Tests the private file transfer system.
- DownloadTest::testPublicFileTransfer in core/
modules/ file/ tests/ src/ Functional/ DownloadTest.php - Tests the public file transfer system.
- FileFieldWidgetTest::testWidgetElement in core/
modules/ file/ tests/ src/ Functional/ FileFieldWidgetTest.php - Tests file widget element.
File
-
core/
tests/ Drupal/ Tests/ BrowserTestBase.php, line 502
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.