protected function EditLoadingTest::retrieveMetadata

Retrieve Edit metadata from the server. May also result in additional JavaScript settings and CSS/JS being loaded.

Parameters

array $ids: An array of edit ids.

Return value

string The response body.

2 calls to EditLoadingTest::retrieveMetadata()
EditLoadingTest::testUserWithoutPermission in drupal/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php
Test the loading of Edit when a user doesn't have access to it.
EditLoadingTest::testUserWithPermission in drupal/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php
Tests the loading of Edit when a user does have access to it.

File

drupal/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php, line 163
Contains \Drupal\edit\Tests\EditLoadingTest.

Class

EditLoadingTest
Tests loading of Edit and lazy-loading of in-place editors.

Namespace

Drupal\edit\Tests

Code

protected function retrieveMetadata($ids) {

  // Build POST values.
  $post = array();
  for ($i = 0; $i < count($ids); $i++) {
    $post['fields[' . $i . ']'] = $ids[$i];
  }

  // Serialize POST values.
  foreach ($post as $key => $value) {

    // Encode according to application/x-www-form-urlencoded
    // Both names and values needs to be urlencoded, according to
    // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
    $post[$key] = urlencode($key) . '=' . urlencode($value);
  }
  $post = implode('&', $post);

  // Perform HTTP request.
  return $this
    ->curlExec(array(
    CURLOPT_URL => url('edit/metadata', array(
      'absolute' => TRUE,
    )),
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => $post . $this
      ->getAjaxPageStatePostData(),
    CURLOPT_HTTPHEADER => array(
      'Accept: application/json',
      'Content-Type: application/x-www-form-urlencoded',
    ),
  ));
}