You are here

protected function WebTestBase::translatePostValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::translatePostValues()

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().

3 calls to WebTestBase::translatePostValues()
InstallerExistingDatabaseSettingsTest::setUpSettings in core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php
@todo The database settings form is not supposed to appear if settings.php contains a valid database connection already (but e.g. no config directories yet).
InstallerTestBase::setUpSettings in core/modules/simpletest/src/InstallerTestBase.php
Installer step: Configure settings.
InstallerTestBase::setUpSite in core/modules/simpletest/src/InstallerTestBase.php
Final installer step: Configure site.

File

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

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

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

  // 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;
}