function WebTestBase::drupalPost
Perform a POST HTTP request.
Parameters
string|\Drupal\Core\Url $path: Drupal path or absolute path where the request should be POSTed.
string $accept: The value for the "Accept" header. Usually either 'application/json' or 'application/vnd.drupal-ajax'.
array $post: The POST data. When making a 'application/vnd.drupal-ajax' request, the Ajax page state data should be included. Use getAjaxPageStatePostData() for that.
array $options: (optional) Options to be forwarded to the url generator. The 'absolute' option will automatically be enabled.
Return value
The content returned from the call to curl_exec().
See also
WebTestBase::getAjaxPageStatePostData()
1 call to WebTestBase::drupalPost()
- WebTestBase::drupalPostWithFormat in core/
modules/ simpletest/ src/ WebTestBase.php - Performs a POST HTTP request with a specific format.
File
-
core/
modules/ simpletest/ src/ WebTestBase.php, line 1361
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
protected function drupalPost($path, $accept, array $post, $options = []) {
return $this->curlExec([
CURLOPT_URL => $this->buildUrl($path, $options),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $this->serializePostValues($post),
CURLOPT_HTTPHEADER => [
'Accept: ' . $accept,
'Content-Type: application/x-www-form-urlencoded',
],
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.