You are here

protected function WebTestBase::translatePostValues in SimpleTest 8.3

Transforms a nested array into a flat array suitable for WebTestBase::drupalPostForm().

Parameters

array $values: A multi-dimensional form values array to convert.

Return value

array The flattened $edit array suitable for WebTestBase::drupalPostForm().

2 calls to WebTestBase::translatePostValues()
InstallerTestBase::setUpSettings in src/InstallerTestBase.php
Installer step: Configure settings.
InstallerTestBase::setUpSite in src/InstallerTestBase.php
Final installer step: Configure site.

File

src/WebTestBase.php, line 1450

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function translatePostValues(array $values) {
  $edit = [];

  // The easiest and most straightforward way to translate values suitable for
  // WebTestBase::drupalPostForm() is to actually build the POST data string
  // and convert the resulting key/value pairs back into a flat array.
  $query = http_build_query($values);
  foreach (explode('&', $query) as $item) {
    list($key, $value) = explode('=', $item);
    $edit[urldecode($key)] = urldecode($value);
  }
  return $edit;
}