You are here

protected function BrowserTestBase::translatePostValues in Drupal 9

Same name and namespace in other branches
  1. 8 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().

8 calls to BrowserTestBase::translatePostValues()
CredentialFormTest::testCredentialFrom in core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
Test the credential form.
DoubleSlashTest::testMigrateUpgradeExecute in core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
Executes all steps of migrations upgrade.
FilePathTest::testFilePath in core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php
Executes all steps of migrations upgrade.
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.

... See full list

File

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

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) {
    list($key, $value) = explode('=', $item);
    $edit[urldecode($key)] = urldecode($value);
  }
  return $edit;
}