You are here

public function DrupalTestBrowser::addPostFields in Drupal 9

Adds form parameters to the $multipart array.

Parameters

array $formParams: The form parameters.

array $multipart: A reference to the multipart array to add the form parameters to.

string $array_name: Internal parameter used by recursive calls.

1 call to DrupalTestBrowser::addPostFields()
DrupalTestBrowser::doRequest in core/tests/Drupal/Tests/DrupalTestBrowser.php

File

core/tests/Drupal/Tests/DrupalTestBrowser.php, line 211

Class

DrupalTestBrowser
Enables a BrowserKitDriver mink driver to use a Guzzle client.

Namespace

Drupal\Tests

Code

public function addPostFields(array $formParams, array &$multipart, $array_name = '') {
  foreach ($formParams as $name => $value) {
    if (!empty($array_name)) {
      $name = $array_name . '[' . $name . ']';
    }
    if (\is_array($value)) {
      $this
        ->addPostFields($value, $multipart, $name);
    }
    else {
      $multipart[] = [
        'name' => $name,
        'contents' => $value,
      ];
    }
  }
}