Verified Commit 2771a312 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3393338 by Berdir, smustgrave: Provide backwards-compatibility for...

Issue #3393338 by Berdir, smustgrave: Provide backwards-compatibility for storage settings in FieldUiTestTrait::fieldUIAddNewField
parent e2f9ad3f
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ public function testCommentFunctionality() {

    // Add a new comment field.
    $storage_edit = [
      'field_storage[subform][settings][comment_type]' => 'foobar',
      'settings[comment_type]' => 'foobar',
    ];
    $this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit);

+1 −1
Original line number Diff line number Diff line
@@ -381,7 +381,7 @@ protected function createEntityReferenceField($target_type, $bundles = []) {
    $field_name = $this->randomMachineName();

    $storage_edit = $field_edit = [];
    $storage_edit['field_storage[subform][settings][target_type]'] = $target_type;
    $storage_edit['settings[target_type]'] = $target_type;
    foreach ($bundles as $bundle) {
      $field_edit['settings[handler_settings][target_bundles][' . $bundle . ']'] = TRUE;
    }
+16 −1
Original line number Diff line number Diff line
@@ -84,8 +84,23 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
      // Test Breadcrumbs.
      $this->getSession()->getPage()->findLink($label);

      // Ensure that each array key in $storage_edit is prefixed with field_storage.
      $prefixed_storage_edit = [];
      foreach ($storage_edit as $key => $value) {
        if (str_starts_with($key, 'field_storage')) {
          $prefixed_storage_edit[$key] = $value;
          continue;
        }
        // If the key starts with settings, it needs to be prefixed differently.
        if (str_starts_with($key, 'settings[')) {
          $prefixed_storage_edit[str_replace('settings[', 'field_storage[subform][settings][', $key)] = $value;
          continue;
        }
        $prefixed_storage_edit['field_storage[subform][' . $key . ']'] = $value;
      }

      // Second step: 'Storage settings' form.
      $this->submitForm($storage_edit, 'Update settings');
      $this->submitForm($prefixed_storage_edit, 'Update settings');

      // Third step: 'Field settings' form.
      $this->submitForm($field_edit, 'Save settings');
+1 −1
Original line number Diff line number Diff line
@@ -302,7 +302,7 @@ public function testPrivateFileComment() {

    $name = $this->randomMachineName();
    $label = $this->randomMachineName();
    $storage_edit = ['field_storage[subform][settings][uri_scheme]' => 'private'];
    $storage_edit = ['settings[uri_scheme]' => 'private'];
    $this->fieldUIAddNewField('admin/structure/comment/manage/comment', $name, $label, 'file', $storage_edit);

    // Manually clear cache on the tester side.
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ public function runFieldUIItem($cardinality, $link_type, $title, $label, $field_
      $field_edit['default_value_input[field_' . $field_name . '][0][title]'] = 'Default title';
    }
    $storage_edit = [
      'field_storage[subform][cardinality_number]' => $cardinality,
      'cardinality_number' => $cardinality,
    ];
    $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', $storage_edit, $field_edit);