You are here

protected function BrowserTestBase::translatePostValues in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::translatePostValues()
  2. 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::translatePostValues()

Transforms a nested array into a flat array suitable for submitForm().

Parameters

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

Return value

array The flattened $edit array suitable for BrowserTestBase::submitForm().

4 calls to BrowserTestBase::translatePostValues()
InstallerExistingDatabaseSettingsTest::setUpSettings in core/tests/Drupal/FunctionalTests/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).
InstallerNonDefaultDatabaseDriverTest::setUpSettings in core/tests/Drupal/FunctionalTests/Installer/InstallerNonDefaultDatabaseDriverTest.php
Installer step: Configure settings.
InstallerTestBase::setUpSettings in core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
Installer step: Configure settings.
InstallerTestBase::setUpSite in core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
Final installer step: Configure site.

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 689

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

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

  // The easiest and most straightforward way to translate values suitable for
  // BrowserTestBase::submitForm() 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) {
    [
      $key,
      $value,
    ] = explode('=', $item);
    $edit[urldecode($key)] = urldecode($value);
  }
  return $edit;
}