function HttpKernelUiHelperTrait::drupalGet
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/HttpKernelUiHelperTrait.php \Drupal\Tests\HttpKernelUiHelperTrait::drupalGet()
Retrieves a Drupal path.
Requests are sent to the HTTP kernel.
Parameters
string $path: The Drupal path to load into Mink controlled browser. (Note that the Symfony browser's functionality of paths relative to the previous request is not available, because an initial '/' is assumed if not present.)
Return value
string The retrieved HTML string.
See also
\Drupal\Tests\BrowserTestBase::getHttpClient()
File
-
core/
tests/ Drupal/ Tests/ HttpKernelUiHelperTrait.php, line 55
Class
- HttpKernelUiHelperTrait
- Provides UI helper methods using the HTTP kernel to make requests.
Namespace
Drupal\TestsCode
protected function drupalGet($path) : string {
$session = $this->getSession();
if (!str_starts_with($path, '/')) {
$path = '/' . $path;
}
$session->visit($path);
$out = $session->getPage()
->getContent();
if ($this->htmlOutputEnabled) {
$html_output = 'GET request to: ' . $path;
$html_output .= '<hr />' . $out;
$html_output .= $this->getHtmlOutputHeaders();
$this->htmlOutput($html_output);
}
return $out;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.