You are here

protected function WebTestBase::drupalPost in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\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()

WebTestBase::curlExec()

14 calls to WebTestBase::drupalPost()
DestinationTest::testDestination in core/modules/system/src/Tests/Routing/DestinationTest.php
Tests that $_GET/$_REQUEST['destination'] only contain internal URLs.
MenuTest::testBlockContextualLinks in core/modules/menu_ui/src/Tests/MenuTest.php
Tests the contextual links on a menu block.
PreviewTest::clickPreviewLinkAJAX in core/modules/views_ui/src/Tests/PreviewTest.php
Mimic clicking on a preview link.
QuickEditAutocompleteTermTest::testAutocompleteQuickEdit in core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
Tests Quick Edit autocomplete term behavior.
QuickEditIntegrationLoadingTest::testUsersWithoutPermission in core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
Test loading of untransformed text when a user doesn't have access to it.

... See full list

File

core/modules/simpletest/src/WebTestBase.php, line 2098
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalPost($path, $accept, array $post, $options = array()) {
  return $this
    ->curlExec(array(
    CURLOPT_URL => $this
      ->buildUrl($path, $options),
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => $this
      ->serializePostValues($post),
    CURLOPT_HTTPHEADER => array(
      'Accept: ' . $accept,
      'Content-Type: application/x-www-form-urlencoded',
    ),
  ));
}