Skip to content
Snippets Groups Projects
Commit 21dbe7c3 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Issue #3433816 by Berdir, jurgenhaas: Automated Drupal 11 compatibility fixes for paragraphs

parent c5bc87f6
No related branches found
No related tags found
1 merge request!115Issue #3433816: Drupal 11 compatibility
Pipeline #244023 passed with warnings
Showing
with 137 additions and 193 deletions
...@@ -49,10 +49,25 @@ include: ...@@ -49,10 +49,25 @@ include:
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml # Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################ ################
variables: variables:
KUBERNETES_CPU_REQUEST: "5"
_CONCURRENCY_THREADS: 20
_PHPUNIT_CONCURRENT: '1' _PHPUNIT_CONCURRENT: '1'
OPT_IN_TEST_PREVIOUS_MINOR: 1 OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_MAX_PHP: 1 # Previous minor defaults to the last security release, currently 10.2.2.
# Override that to 10.2.7 to avoid MigrateSourceTestBase::providerSource()
# related errors.
composer (previous minor):
variables:
DRUPAL_CORE: 10.2.7
composer (next major):
variables:
_LENIENT_ALLOW_LIST: "inline_entity_form"
phpunit (next major):
before_script:
- 'sed -i "s/core_version_requirement.*/core_version_requirement: \^11/" web/modules/contrib/**/*.info.yml'
################################################################################### ###################################################################################
# #
......
description: 'Provides multilingual demo Paragraphs types.' description: 'Provides multilingual demo Paragraphs types.'
core_version_requirement: ^9.3 || ^10 core_version_requirement: ^10.2 || ^11
dependencies: dependencies:
- paragraphs:paragraphs - paragraphs:paragraphs
- drupal:field - drupal:field
......
name: Paragraphs Library name: Paragraphs Library
type: module type: module
description: 'Provides a library for reusing paragraphs.' description: 'Provides a library for reusing paragraphs.'
core_version_requirement: ^9.3 || ^10 core_version_requirement: ^10.2 || ^11
package: Paragraphs package: Paragraphs
configure: paragraphs_library_item.settings configure: paragraphs_library_item.settings
dependencies: dependencies:
......
...@@ -297,12 +297,7 @@ class ParagraphsLibraryTest extends ParagraphsTestBase { ...@@ -297,12 +297,7 @@ class ParagraphsLibraryTest extends ParagraphsTestBase {
$this->assertSession()->buttonExists('Save configuration'); $this->assertSession()->buttonExists('Save configuration');
// Assert that users can create fields to // Assert that users can create fields to
$this->clickLink('Manage fields'); $this->clickLink('Manage fields');
if (version_compare(\Drupal::VERSION, '10.1', '>=')) { $this->clickLink('Create a new field');
$this->clickLink('Create a new field');
}
else {
$this->clickLink('Add field');
}
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextNotContains('plugin does not exist'); $this->assertSession()->pageTextNotContains('plugin does not exist');
$this->drupalGet('admin/config/content'); $this->drupalGet('admin/config/content');
......
name: Paragraphs Type Permissions name: Paragraphs Type Permissions
type: module type: module
description: 'Allows users to configure permissions for individual Paragraphs types.' description: 'Allows users to configure permissions for individual Paragraphs types.'
core_version_requirement: ^9.3 || ^10 core_version_requirement: ^10.2 || ^11
package: Paragraphs package: Paragraphs
dependencies: dependencies:
......
name: Paragraphs name: Paragraphs
type: module type: module
description: 'Enables the creation of paragraphs entities.' description: 'Enables the creation of paragraphs entities.'
core_version_requirement: ^9.3 || ^10 core_version_requirement: ^10.2 || ^11
package: Paragraphs package: Paragraphs
configure: entity.paragraphs_type.collection configure: entity.paragraphs_type.collection
......
...@@ -127,18 +127,43 @@ function paragraphs_form_entity_form_display_edit_form_alter(&$form, FormStateIn ...@@ -127,18 +127,43 @@ function paragraphs_form_entity_form_display_edit_form_alter(&$form, FormStateIn
/** /**
* Implements hook_form_FORM_ID_alter(). * Implements hook_form_FORM_ID_alter().
*
* Indicate unsupported multilingual paragraphs field configuration.
*/ */
function paragraphs_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { function paragraphs_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_state->getFormObject()->getEntity()->getType() == 'entity_reference') { $field = $form_state->getFormObject()->getEntity();
if (version_compare(\Drupal::VERSION, '10.2', '>')) { if (\Drupal::hasService('content_translation.manager')) {
$selector = 'field_storage[subform][settings][target_type]'; $bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->getTargetEntityTypeId(), $field->getTargetBundle());
}
else { if ($bundle_is_translatable && $field->getType() === 'entity_reference_revisions' && $field->getSetting('target_type') === 'paragraph') {
$selector = 'settings[target_type]'; // This is a translatable ERR field pointing to a paragraph.
$message_display = 'warning';
$message_text = t('Paragraphs fields do not support translation. See the <a href=":documentation">online documentation</a>.', [
':documentation' => Url::fromUri('https://www.drupal.org/node/2735121')
->toString()
]);
if ($form['translatable']['#default_value'] == TRUE) {
$message_display = 'error';
}
$form['paragraphs_message'] = [
'#type' => 'container',
'#markup' => $message_text,
'#attributes' => [
'class' => ['messages messages--' . $message_display],
],
'#weight' => 0,
];
} }
}
if ($field->getType() == 'entity_reference') {
$selector = 'field_storage[subform][settings][target_type]';
// Add a note about paragraphs if selected. // Add a note about paragraphs if selected.
$form['settings']['paragraph_warning_wrapper'] = [ $form['field_storage']['subform']['settings']['paragraph_warning_wrapper'] = [
'#type' => 'container', '#type' => 'container',
'#states' => [ '#states' => [
'visible' => [ 'visible' => [
...@@ -158,58 +183,13 @@ function paragraphs_form_field_storage_config_edit_form_alter(&$form, FormStateI ...@@ -158,58 +183,13 @@ function paragraphs_form_field_storage_config_edit_form_alter(&$form, FormStateI
], ],
]; ];
} }
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Indicate unsupported multilingual paragraphs field configuration.
*/
function paragraphs_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$field = $form_state->getFormObject()->getEntity();
if (!\Drupal::hasService('content_translation.manager')) {
return;
}
$bundle_is_translatable = \Drupal::service('content_translation.manager')
->isEnabled($field->getTargetEntityTypeId(), $field->getTargetBundle());
if (!$bundle_is_translatable
|| $field->getType() != 'entity_reference_revisions'
|| $field->getSetting('target_type') != 'paragraph') {
return;
}
// This is a translatable ERR field pointing to a paragraph.
$message_display = 'warning';
$message_text = t('Paragraphs fields do not support translation. See the <a href=":documentation">online documentation</a>.', [
':documentation' => Url::fromUri('https://www.drupal.org/node/2735121')
->toString()
]);
if ($form['translatable']['#default_value'] == TRUE) {
$message_display = 'error';
}
$form['paragraphs_message'] = array(
'#type' => 'container',
'#markup' => $message_text,
'#attributes' => array(
'class' => array('messages messages--' . $message_display),
),
'#weight' => 0,
);
} }
function paragraphs_field_ui_preconfigured_options_alter(array &$options, $field_type) { function paragraphs_field_ui_preconfigured_options_alter(array &$options, $field_type) {
// Move the preconfigured paragraph option to the generic category,
if (version_compare(\Drupal::VERSION, '10.2', '<')) { // so it is available as a top-level option in the new field type selection
return; // UI in Drupal 10.2+.
}
// Move the preconfigured paragraph option to the generic category so it is available
// as a top-level option in the new field type selection UI in Drupal 10.2+.
if ($field_type == 'entity_reference_revisions' && !empty($options['paragraph'])) { if ($field_type == 'entity_reference_revisions' && !empty($options['paragraph'])) {
$options['paragraph']['weight'] = -15; $options['paragraph']['weight'] = -15;
$options['paragraph']['category'] = FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY;; $options['paragraph']['category'] = FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY;;
......
...@@ -98,7 +98,7 @@ class ParagraphsTypeForm extends EntityForm { ...@@ -98,7 +98,7 @@ class ParagraphsTypeForm extends EntityForm {
'#type' => 'managed_file', '#type' => 'managed_file',
'#upload_location' => ParagraphsTypeInterface::ICON_UPLOAD_LOCATION, '#upload_location' => ParagraphsTypeInterface::ICON_UPLOAD_LOCATION,
'#upload_validators' => [ '#upload_validators' => [
'file_validate_extensions' => ['png jpg svg'], 'FileExtension' => ['extensions' => 'png jpg svg'],
], ],
]; ];
......
...@@ -25,6 +25,11 @@ class FieldCollection extends FieldPluginBase { ...@@ -25,6 +25,11 @@ class FieldCollection extends FieldPluginBase {
*/ */
const FIELD_COLLECTION_PREFIX_LENGTH = 6; const FIELD_COLLECTION_PREFIX_LENGTH = 6;
/**
* Recursion counter.
*/
static int $recursionCounter = 0;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -65,6 +70,15 @@ class FieldCollection extends FieldPluginBase { ...@@ -65,6 +70,15 @@ class FieldCollection extends FieldPluginBase {
]; ];
$migration->setProcessOfProperty($field_name, $process); $migration->setProcessOfProperty($field_name, $process);
// Workaround for recursion on D11+, because getMigrationDependencies()
// expands plugins, it will go through the deriver again, which will create
// a stub migration again.
if (static::$recursionCounter > 0) {
return;
}
static::$recursionCounter++;
// Add the respective field collection migration as a dependency. // Add the respective field collection migration as a dependency.
$migration_dependency = 'd7_field_collection:' . substr($field_name, static::FIELD_COLLECTION_PREFIX_LENGTH); $migration_dependency = 'd7_field_collection:' . substr($field_name, static::FIELD_COLLECTION_PREFIX_LENGTH);
$migration_rev_dependency = 'd7_field_collection_revisions:' . substr($field_name, static::FIELD_COLLECTION_PREFIX_LENGTH); $migration_rev_dependency = 'd7_field_collection_revisions:' . substr($field_name, static::FIELD_COLLECTION_PREFIX_LENGTH);
...@@ -76,6 +90,8 @@ class FieldCollection extends FieldPluginBase { ...@@ -76,6 +90,8 @@ class FieldCollection extends FieldPluginBase {
$dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [$migration_rev_dependency])); $dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [$migration_rev_dependency]));
$migration->set('migration_dependencies', $dependencies); $migration->set('migration_dependencies', $dependencies);
} }
static::$recursionCounter--;
} }
/** /**
......
...@@ -20,6 +20,11 @@ use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; ...@@ -20,6 +20,11 @@ use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
*/ */
class Paragraphs extends FieldPluginBase { class Paragraphs extends FieldPluginBase {
/**
* Recursion counter.
*/
static int $recursionCounter = 0;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -67,6 +72,15 @@ class Paragraphs extends FieldPluginBase { ...@@ -67,6 +72,15 @@ class Paragraphs extends FieldPluginBase {
// @todo: This is a great example why we should consider derive paragraph // @todo: This is a great example why we should consider derive paragraph
// migrations based on parent entity type (and bundle). // migrations based on parent entity type (and bundle).
if (!in_array('Paragraphs Content', $migration->getMigrationTags(), TRUE)) { if (!in_array('Paragraphs Content', $migration->getMigrationTags(), TRUE)) {
// Workaround for recursion on D11+, because getMigrationDependencies()
// expands plugins, it will go through the deriver again, which will create
// a stub migration again.
if (static::$recursionCounter > 0) {
return;
}
static::$recursionCounter++;
$dependencies = $migration->getMigrationDependencies() + ['required' => []]; $dependencies = $migration->getMigrationDependencies() + ['required' => []];
$dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [ $dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [
'd7_paragraphs', 'd7_paragraphs',
...@@ -79,6 +93,8 @@ class Paragraphs extends FieldPluginBase { ...@@ -79,6 +93,8 @@ class Paragraphs extends FieldPluginBase {
])); ]));
$migration->set('migration_dependencies', $dependencies); $migration->set('migration_dependencies', $dependencies);
} }
static::$recursionCounter--;
} }
} }
......
...@@ -40,7 +40,7 @@ class MigrateUiParagraphsTest extends MigrateUiParagraphsTestBase { ...@@ -40,7 +40,7 @@ class MigrateUiParagraphsTest extends MigrateUiParagraphsTestBase {
* @return bool[][] * @return bool[][]
* Classic node migration type. * Classic node migration type.
*/ */
public function providerParagraphsMigrate() { public static function providerParagraphsMigrate() {
return [ return [
['node_migrate_type_classic' => TRUE], ['node_migrate_type_classic' => TRUE],
['node_migrate_type_classic' => FALSE], ['node_migrate_type_classic' => FALSE],
......
...@@ -420,6 +420,7 @@ abstract class MigrateUiParagraphsTestBase extends MigrateUpgradeTestBase { ...@@ -420,6 +420,7 @@ abstract class MigrateUiParagraphsTestBase extends MigrateUpgradeTestBase {
$form = $drivers[$driver]->getInstallTasks()->getFormOptions($connection_options); $form = $drivers[$driver]->getInstallTasks()->getFormOptions($connection_options);
} }
else { else {
// @phpstan-ignore-next-line
$drivers = drupal_get_database_types(); $drivers = drupal_get_database_types();
$form = $drivers[$driver]->getFormOptions($connection_options); $form = $drivers[$driver]->getFormOptions($connection_options);
} }
......
...@@ -107,12 +107,7 @@ class ParagraphsUiTest extends ParagraphsTestBase { ...@@ -107,12 +107,7 @@ class ParagraphsUiTest extends ParagraphsTestBase {
], 'Save and manage fields'); ], 'Save and manage fields');
// Add a new paragraphs field to the content type. // Add a new paragraphs field to the content type.
if (version_compare(\Drupal::VERSION, '10.1', '>=')) { $this->clickLink('Create a new field');
$this->clickLink('Create a new field');
}
else {
$this->clickLink('Add field');
}
$this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph');
if ($this->coreVersion('10.3')) { if ($this->coreVersion('10.3')) {
...@@ -122,10 +117,7 @@ class ParagraphsUiTest extends ParagraphsTestBase { ...@@ -122,10 +117,7 @@ class ParagraphsUiTest extends ParagraphsTestBase {
'label' => 'Paragraph', 'label' => 'Paragraph',
'field_name' => 'paragraph', 'field_name' => 'paragraph',
]; ];
$this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); $this->submitForm($edit, 'Continue');
if (!$this->coreVersion('10.2')) {
$this->submitForm([], 'Save field settings');
}
$this->submitForm([], 'Save settings'); $this->submitForm([], 'Save settings');
// Visit the "Manage form display" page of the new content type. // Visit the "Manage form display" page of the new content type.
......
...@@ -101,20 +101,11 @@ class ParagraphsAccessTest extends ParagraphsTestBase { ...@@ -101,20 +101,11 @@ class ParagraphsAccessTest extends ParagraphsTestBase {
$role->save(); $role->save();
// Set field_images from demo to private file storage. // Set field_images from demo to private file storage.
if ($this->coreVersion('10.2')) { $edit = array(
$edit = array( 'field_storage[subform][settings][uri_scheme]' => 'private',
'field_storage[subform][settings][uri_scheme]' => 'private', );
); $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo');
$this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); $this->submitForm($edit, 'Save settings');
$this->submitForm($edit, 'Save settings');
}
else {
$edit = array(
'settings[uri_scheme]' => 'private',
);
$this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo/storage');
$this->submitForm($edit, 'Save field settings');
}
// Set the form display to legacy. // Set the form display to legacy.
$form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default') $form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default')
......
...@@ -153,10 +153,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { ...@@ -153,10 +153,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase {
'label' => 'Paragraph', 'label' => 'Paragraph',
'field_name' => 'paragraph', 'field_name' => 'paragraph',
]; ];
$this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); $this->submitForm($edit, 'Continue');
if (!$this->coreVersion('10.2')) {
$this->submitForm([], 'Save field settings');
}
$this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add'); $this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add');
$this->clickLink('here'); $this->clickLink('here');
...@@ -441,15 +438,8 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { ...@@ -441,15 +438,8 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase {
$this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.'); $this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.');
// Set the fields as not required. // Set the fields as not required.
if ($this->coreVersion('10.2')) { $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs');
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); $this->submitForm(['required' => FALSE], 'Save');
$this->submitForm(['required' => FALSE], 'Save');
}
else {
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->clickLink('Edit');
$this->submitForm(['required' => FALSE], 'Save settings');
}
// Set the Paragraph field edit mode to 'Closed'. // Set the Paragraph field edit mode to 'Closed'.
$this->drupalGet('admin/structure/types/manage/article/form-display'); $this->drupalGet('admin/structure/types/manage/article/form-display');
......
...@@ -125,27 +125,16 @@ class ParagraphsConfigTest extends ParagraphsTestBase { ...@@ -125,27 +125,16 @@ class ParagraphsConfigTest extends ParagraphsTestBase {
// Check a not paragraphs translatable field does not display the message. // Check a not paragraphs translatable field does not display the message.
$this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field'); $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field');
if ($this->coreVersion('10.2')) { $selected_group = [
$selected_group = [ 'new_storage_type' => 'reference',
'new_storage_type' => 'reference', ];
]; $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group');
$this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); $edit = [
$edit = [ 'group_field_options_wrapper' => 'field_ui:entity_reference:node',
'group_field_options_wrapper' => 'field_ui:entity_reference:node', 'label' => 'new_no_field_paragraphs',
'label' => 'new_no_field_paragraphs', 'field_name' => 'new_no_field_paragraphs',
'field_name' => 'new_no_field_paragraphs', ];
]; $this->submitForm($edit, 'Continue');
$this->submitForm($edit, 'Continue');
}
else {
$edit = [
'new_storage_type' => 'field_ui:entity_reference:node',
'label' => 'new_no_paragraphs_field',
'field_name' => 'new_no_paragraphs_field',
];
$this->submitForm($edit, 'Save and continue');
$this->submitForm([], 'Save field settings');
}
$this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.'); $this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.');
$this->assertSession()->responseNotContains('<div class="messages messages--warning'); $this->assertSession()->responseNotContains('<div class="messages messages--warning');
} }
......
...@@ -93,21 +93,11 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { ...@@ -93,21 +93,11 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase {
]); ]);
// Set cardinality explicit to -1. // Set cardinality explicit to -1.
if ($this->coreVersion('10.2')) { $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs');
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); $edit = [
$edit = [ 'field_storage[subform][cardinality]' => '-1',
'field_storage[subform][cardinality]' => '-1', ];
]; $this->submitForm($edit, 'Save settings');
$this->submitForm($edit, 'Save settings');
}
else {
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs/storage');
$edit = [
'settings[target_type]' => 'paragraph',
'cardinality' => '-1',
];
$this->submitForm($edit, 'Save field settings');
}
// Enable IEF simple widget. // Enable IEF simple widget.
$this->drupalGet('admin/structure/paragraphs_type/simple/form-display'); $this->drupalGet('admin/structure/paragraphs_type/simple/form-display');
......
...@@ -103,20 +103,11 @@ class ParagraphsAccessTest extends ParagraphsTestBase { ...@@ -103,20 +103,11 @@ class ParagraphsAccessTest extends ParagraphsTestBase {
$role->save(); $role->save();
// Set field_images from demo to private file storage. // Set field_images from demo to private file storage.
if ($this->coreVersion('10.2')) { $edit = array(
$edit = array( 'field_storage[subform][settings][uri_scheme]' => 'private',
'field_storage[subform][settings][uri_scheme]' => 'private', );
); $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo');
$this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); $this->submitForm($edit, 'Save settings');
$this->submitForm($edit, 'Save settings');
}
else {
$edit = array(
'settings[uri_scheme]' => 'private',
);
$this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo/storage');
$this->submitForm($edit, 'Save field settings');
}
// Use the stable widget. // Use the stable widget.
$form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default') $form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default')
......
...@@ -156,10 +156,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { ...@@ -156,10 +156,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase {
'label' => 'Paragraph', 'label' => 'Paragraph',
'field_name' => 'paragraph', 'field_name' => 'paragraph',
]; ];
$this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); $this->submitForm($edit, 'Continue');
if (!$this->coreVersion('10.2')) {
$this->submitForm([], 'Save field settings');
}
$this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add'); $this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add');
$this->clickLink('here'); $this->clickLink('here');
...@@ -446,15 +443,8 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { ...@@ -446,15 +443,8 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase {
$this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.'); $this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.');
// Set the fields as not required. // Set the fields as not required.
if ($this->coreVersion('10.2')) { $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs');
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); $this->submitForm(['required' => FALSE], 'Save');
$this->submitForm(['required' => FALSE], 'Save');
}
else {
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->clickLink('Edit');
$this->submitForm(['required' => FALSE], 'Save settings');
}
// Set the Paragraph field edit mode to "Closed" and the closed mode to // Set the Paragraph field edit mode to "Closed" and the closed mode to
// "Summary". // "Summary".
......
...@@ -124,29 +124,17 @@ class ParagraphsConfigTest extends ParagraphsTestBase { ...@@ -124,29 +124,17 @@ class ParagraphsConfigTest extends ParagraphsTestBase {
$this->assertSession()->responseContains('<div class="messages messages--error'); $this->assertSession()->responseContains('<div class="messages messages--error');
// Check a not paragraphs translatable field does not display the message. // Check a not paragraphs translatable field does not display the message.
if ($this->coreVersion('10.2')) { $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field');
$this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field'); $selected_group = [
$selected_group = [ 'new_storage_type' => 'reference',
'new_storage_type' => 'reference', ];
]; $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group');
$this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); $edit = [
$edit = [ 'group_field_options_wrapper' => 'field_ui:entity_reference:node',
'group_field_options_wrapper' => 'field_ui:entity_reference:node', 'label' => 'new_no_field_paragraphs',
'label' => 'new_no_field_paragraphs', 'field_name' => 'new_no_field_paragraphs',
'field_name' => 'new_no_field_paragraphs', ];
]; $this->submitForm($edit, 'Continue');
$this->submitForm($edit, 'Continue');
}
else {
$this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field');
$edit = [
'new_storage_type' => 'field_ui:entity_reference:node',
'label' => 'new_no_field_paragraphs',
'field_name' => 'new_no_field_paragraphs',
];
$this->submitForm($edit, 'Save and continue');
$this->submitForm([], 'Save field settings');
}
$this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.'); $this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.');
$this->assertSession()->responseNotContains('<div class="messages messages--warning'); $this->assertSession()->responseNotContains('<div class="messages messages--warning');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment