You are here

protected function ProcessorIntegrationTest::getFormValues in Search API 8

Converts a configuration array into an array of form values.

Parameters

array $configuration: The configuration to convert.

string $prefix: The common prefix for all form values.

Return value

string[] An array of form values ready for submission.

2 calls to ProcessorIntegrationTest::getFormValues()
ProcessorIntegrationTest::checkValidationError in tests/src/Functional/ProcessorIntegrationTest.php
Makes sure that the given form values will fail when submitted.
ProcessorIntegrationTest::editSettingsForm in tests/src/Functional/ProcessorIntegrationTest.php
Enables a processor with a given configuration.

File

tests/src/Functional/ProcessorIntegrationTest.php, line 843

Class

ProcessorIntegrationTest
Tests the admin UI for processors.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function getFormValues(array $configuration, $prefix) {
  $edit = [];
  foreach ($configuration as $key => $value) {
    $key = $prefix . "[{$key}]";
    if (is_array($value)) {

      // Handling of numerically indexed and associative arrays needs to be
      // different.
      if ($value == array_values($value)) {
        $key .= '[]';
        $edit[$key] = $value;
      }
      else {
        $edit += $this
          ->getFormValues($value, $key);
      }
    }
    else {
      $edit[$key] = $value;
    }
  }
  return $edit;
}