function BrowserTestBase::translatePostValues

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::translatePostValues()
  2. 10 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::translatePostValues()
  3. 11.x 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().

9 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 702

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.