diff --git a/composer.json b/composer.json index 3461832e1f250010b26fd0f0b53c8b2a34a2b72e..88d4c1ae11d05d8227163882fdc1c271c3c0793e 100644 --- a/composer.json +++ b/composer.json @@ -138,7 +138,7 @@ "drupal/msqrole": "^1.0", "drupal/multiple_fields_remove_button": "2.2.0", "drupal/pantheon_advanced_page_cache": "2.2.0", - "drupal/paragraphs": "1.17", + "drupal/paragraphs": "1.18", "drupal/pathauto": "1.13", "drupal/queue_mail": "^1.4", "drupal/realname": "^2.0@beta", diff --git a/composer.lock b/composer.lock index ac140a76c1fad459e9fadc29e983bc3ce555b84d..a601429c699dfdb04edabe1c71f2f940e9279f5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f11ea72ebbd736d36ec8bd0c1b998bef", + "content-hash": "88fc18284c651171c263a6a017c4cfeb", "packages": [ { "name": "algolia/places", @@ -5137,20 +5137,20 @@ }, { "name": "drupal/paragraphs", - "version": "1.17.0", + "version": "1.18.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/paragraphs.git", - "reference": "8.x-1.17" + "reference": "8.x-1.18" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/paragraphs-8.x-1.17.zip", - "reference": "8.x-1.17", - "shasum": "81c05f6a1eb59ab957c9ac97b2e79d6c9837bd72" + "url": "https://ftp.drupal.org/files/projects/paragraphs-8.x-1.18.zip", + "reference": "8.x-1.18", + "shasum": "594e2937ea5c95fc88b60420590c4d83f5cd71ee" }, "require": { - "drupal/core": "^9.3 || ^10", + "drupal/core": "^10.2 || ^11", "drupal/entity_reference_revisions": "~1.3" }, "require-dev": { @@ -5158,6 +5158,7 @@ "drupal/diff": "1.x-dev", "drupal/entity_browser": "2.x-dev", "drupal/entity_usage": "2.x-dev", + "drupal/feeds": "^3", "drupal/field_group": "3.x-dev", "drupal/inline_entity_form": "1.x-dev", "drupal/paragraphs-paragraphs_library": "*", @@ -5171,8 +5172,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.17", - "datestamp": "1709804220", + "version": "8.x-1.18", + "datestamp": "1723029144", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9c572c414e43683653015ac7662fe2733d62115a..09d222c7104b4bbb06ed54069ea67e59ca754297 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -5403,21 +5403,21 @@ }, { "name": "drupal/paragraphs", - "version": "1.17.0", - "version_normalized": "1.17.0.0", + "version": "1.18.0", + "version_normalized": "1.18.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/paragraphs.git", - "reference": "8.x-1.17" + "reference": "8.x-1.18" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/paragraphs-8.x-1.17.zip", - "reference": "8.x-1.17", - "shasum": "81c05f6a1eb59ab957c9ac97b2e79d6c9837bd72" + "url": "https://ftp.drupal.org/files/projects/paragraphs-8.x-1.18.zip", + "reference": "8.x-1.18", + "shasum": "594e2937ea5c95fc88b60420590c4d83f5cd71ee" }, "require": { - "drupal/core": "^9.3 || ^10", + "drupal/core": "^10.2 || ^11", "drupal/entity_reference_revisions": "~1.3" }, "require-dev": { @@ -5425,6 +5425,7 @@ "drupal/diff": "1.x-dev", "drupal/entity_browser": "2.x-dev", "drupal/entity_usage": "2.x-dev", + "drupal/feeds": "^3", "drupal/field_group": "3.x-dev", "drupal/inline_entity_form": "1.x-dev", "drupal/paragraphs-paragraphs_library": "*", @@ -5438,8 +5439,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.17", - "datestamp": "1709804220", + "version": "8.x-1.18", + "datestamp": "1723029144", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index e983868f617a394ee42371d882f33b00c01ac339..8d00a22f81076e97c88f9b0c8996ad4e07944001 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '48f6e8b84b15ffa536939cfe8b351e9ad4f0c835', + 'reference' => 'edad21415772d60aa472efd531ce5c0184329d69', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -944,9 +944,9 @@ 'dev_requirement' => false, ), 'drupal/paragraphs' => array( - 'pretty_version' => '1.17.0', - 'version' => '1.17.0.0', - 'reference' => '8.x-1.17', + 'pretty_version' => '1.18.0', + 'version' => '1.18.0.0', + 'reference' => '8.x-1.18', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/paragraphs', 'aliases' => array(), @@ -1564,7 +1564,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '48f6e8b84b15ffa536939cfe8b351e9ad4f0c835', + 'reference' => 'edad21415772d60aa472efd531ce5c0184329d69', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/web/modules/paragraphs/.gitlab-ci.yml b/web/modules/paragraphs/.gitlab-ci.yml index 73282e19d6e2511ba446f984de7b0d2c4ad723f7..dc8b869854a55ce59b6b490646de498ae50d97e6 100644 --- a/web/modules/paragraphs/.gitlab-ci.yml +++ b/web/modules/paragraphs/.gitlab-ci.yml @@ -49,10 +49,25 @@ include: # Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml ################ variables: + KUBERNETES_CPU_REQUEST: "5" + _CONCURRENCY_THREADS: 20 _PHPUNIT_CONCURRENT: '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' ################################################################################### # diff --git a/web/modules/paragraphs/composer.json b/web/modules/paragraphs/composer.json index 3056e994b716b317f70b91aef3afa1541c6f79f3..ad971cf5b9890fb846cb3fd8d06e5878485ff9a9 100644 --- a/web/modules/paragraphs/composer.json +++ b/web/modules/paragraphs/composer.json @@ -17,6 +17,7 @@ "drupal/block_field": "1.x-dev", "drupal/entity_browser": "2.x-dev", "drupal/entity_usage": "2.x-dev", - "drupal/search_api": "^1" + "drupal/search_api": "^1", + "drupal/feeds": "^3" } } diff --git a/web/modules/paragraphs/css/paragraphs.widget.css b/web/modules/paragraphs/css/paragraphs.widget.css index 640fd3a45f4b109405df04d657179ba5bbed1402..1f0ec1e2370e12a22a185fba29f5a84a627f087a 100644 --- a/web/modules/paragraphs/css/paragraphs.widget.css +++ b/web/modules/paragraphs/css/paragraphs.widget.css @@ -168,18 +168,21 @@ margin-right: -11px; } -.js .field--widget-paragraphs .form-actions { +.js .field--widget-paragraphs .form-actions, +.js .field--widget-paragraphs .field-actions { -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center; } -.js .field--widget-paragraphs .form-actions .dropbutton-multiple { +.js .field--widget-paragraphs .form-actions .dropbutton-multiple, +.js .field--widget-paragraphs .field-actions .dropbutton-multiple { margin-right: .5rem; } -.js .field--widget-paragraphs .form-actions .placeholder { +.js .field--widget-paragraphs .form-actions .placeholder, +.js .field--widget-paragraphs .field-actions .placeholder { margin-left: .25em; } @@ -193,7 +196,7 @@ } .js .field--widget-paragraphs .paragraphs-dropbutton-wrapper .dropbutton-multiple { - margin: 0; + margin: 0 .5rem 0 0; } .js .field--widget-paragraphs .dropbutton-wrapper { @@ -220,6 +223,7 @@ margin-top: 3px; padding-right: .25em; width: 23px; + vertical-align: baseline; } .js .field--widget-paragraphs .draggable .tabledrag-handle:focus::before { @@ -230,6 +234,7 @@ .js .field--widget-paragraphs .draggable .tabledrag-handle::after { margin-left: 0; padding: .5rem; + margin-top: 0.9375rem; } .js .field--widget-paragraphs .draggable .tabledrag-handle:hover .handle { @@ -394,15 +399,15 @@ tr:hover .paragraphs-description::after { background: #057ec7 none; } +.js .paragraphs-convert-button { + margin-left: 0; +} + .paragraphs-dragdrop__item .paragraphs-summary-wrapper .paragraphs-description .paragraphs-content-wrapper, .paragraphs-dragdrop__item .paragraphs-summary-wrapper .paragraphs-description .paragraphs-plugin-wrapper { font-size: 81.3%; } -.js .paragraphs-convert-button { - margin-left: 0; -} - .paragraph--view-mode--preview { padding-right: 1em; } diff --git a/web/modules/paragraphs/css/paragraphs.widget.scss b/web/modules/paragraphs/css/paragraphs.widget.scss index c14a521607fbf5e607d3d497ec3f2bdaf8a1fbb2..bc9f05abbc03a90576a036334572a2d9371d765c 100644 --- a/web/modules/paragraphs/css/paragraphs.widget.scss +++ b/web/modules/paragraphs/css/paragraphs.widget.scss @@ -96,8 +96,9 @@ margin-right: -11px; } - // Fix alignment of form-actions. - .form-actions { + // Fix alignment of field-actions / form-actions. + .form-actions, + .field-actions { align-items: center; // Fix alignment to content. @@ -120,7 +121,7 @@ padding: 0; .dropbutton-multiple { - margin: 0; + margin: 0 .5rem 0 0; } } @@ -152,6 +153,7 @@ margin-top: 3px; padding-right: .25em; width: 23px; + vertical-align: baseline; // Fix active focus. &:focus { @@ -165,6 +167,7 @@ &::after { margin-left: 0; padding: .5rem; + margin-top: 0.9375rem; } // Scale the icon on hover. diff --git a/web/modules/paragraphs/logo.png b/web/modules/paragraphs/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..3913081ca4c64235f11774ce1621b8bb04c05746 --- /dev/null +++ b/web/modules/paragraphs/logo.png @@ -0,0 +1,10 @@ +�PNG + +��� IHDR������������&�� IDATx�ҁ�������W�b(�� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��������������������������{��d��8�֮�6b��dl�\۶m��ڶ�;<�56cۙ�U����Ã��k}������*�]:d6��S""B�������y%�6Lt[�4��%"0S�iۖz0J�dbxd�shd���5`F����| 2E�#m;�?0�t���eI�,�\֖���,Ҷ����#ݺ����m������s��L#;������X�G���0� �\���0���_x�S|I��.��L���g��E�u���p2���\���L4�S�� �{��^�I�8�����9 ~�� A!9�)'+ߺ4!�5?p�0 �8��jy�_�U�+��f�\��c�c�Ao(�E������Lh� +0�$zB9A WU��|���]'�2������UC��G@D�h(-*��H�]wWR�W�)��L�#�&L2�N]!�}���x�Y ���,_�K�^��k������#!ᑒ ��#����F:������b"���: �8�� ��! ��G� ��:~�o?����~������j�=t��?���(\H�x�R!�?�n@�o���y`.�-��M�d?!�����Z҉ꗮ�$@"���?�`� ��j>�Ւ����}�҉��}F� B��}�w��)�V[r�4l�aw�nZ���l��o��C�F_���������x�S,�P����ޝ�=9�������)p���W�������/���a����t��ক 9�2Pt����D��>p��>O�9�BD��p ���%���NPp�+#�)��]c��OMp�����c(�[5�P�7�J5Ţ� ��3w�~J��P���u�t������.��@�<~�T˻�*�����ܣ��_�#9�RD� P<�Jl�1~�K-��ZH���(�k<�-���^�B�#@��ڡ�V�-r�>�Vh�����q����1�4���%�J���m 5@�U+�<�ЂfWL-�ܑ�1Cݮ"�@��u��������P�6@&zA��[�9SÓ˯��`r�5��5h��s��`��h��P~@�5(Rr��`����8���X� r���`(�@�4rA�-ғJ���[�c@����Q��"�E�Vj��+���Š�z9�b�H ( ��H&ɱq��"}5!�R-L6�,�kׁ�+���j�Z���)*���7$8�R��"�V�L8�R0�LS+V���hK�հ{[,��hUX�xmLp�������<���H�s׆]��]@��u@I��8�J���}j9C�q������AI�n0� ĩ|�J߁�@�}i�{���� �2qp!���� +ڥ/*D��sG��. cV��k���j �io~�����Sp�t�+^W +.�{� C��>^.�w�!p�d�����Gp�TH{�+��[�͍8�"�.y���b�uD"@Ƌ_�1n�w�8�"b�>��� ~���7�%0{�Ɩw,�4=�O%Px`���{�@���w�8� +�S�U@�ԡ���[�3��OY@pK��>�@�cF��������M���l,Z���>Hg��n�8��g�Q��U��YͿm��天�{�R.���r���1���[���p!�����^�I����k�x.4q��-��R�v,��TU�)qn�u���9�)%\ +�z��T�� ���O{M� X)\� +9���0\F�q���#9��e�RW%�G�}:�eY�w?Р�`n�Ô8���D����{n��D��H�����ϐ��Ar���3�!��Ɯ��]�~��.d^����pmGRׁ (u����QG�������'G@C���i��'���O��@ ��[@V��i%��-ݝ�c� ����q�pL�$G�Ǻ{b���t��)����s씙0c)!��d`��9 �N� ��(|�et NJ�'��4���]:���`tꃬ����������������������������������������������������������������������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��]0���#���U�E�h���_�ϗ�q�d���7����������O�����x�2�g���q4����3Xi���G|�b�s�V�>��g� +����uO��X^m8��������ו�7��\� pq-:��͛�{��\(uvo<��͛�k�]\G<`6>qvʯ�� u!�N�� u���� `��GGg"�'b�ڥc����A����Q �������������������������������������������������������������������������� � � � � � � � � � � � � �L!� � � � �,м\@�=����IEND�B`� \ No newline at end of file diff --git a/web/modules/paragraphs/modules/paragraphs_demo/paragraphs_demo.info.yml b/web/modules/paragraphs/modules/paragraphs_demo/paragraphs_demo.info.yml index f67bb7b184f568c99f795ade0935a99f7aad7a27..e348d1efb0739b01aba27d475d0c2723807098d3 100644 --- a/web/modules/paragraphs/modules/paragraphs_demo/paragraphs_demo.info.yml +++ b/web/modules/paragraphs/modules/paragraphs_demo/paragraphs_demo.info.yml @@ -1,5 +1,5 @@ description: 'Provides multilingual demo Paragraphs types.' -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^10.2 || ^11 dependencies: - paragraphs:paragraphs - drupal:field @@ -21,7 +21,7 @@ name: Paragraphs Demo package: Paragraphs type: module -# Information added by Drupal.org packaging script on 2024-01-14 -version: '8.x-1.17' +# Information added by Drupal.org packaging script on 2024-08-07 +version: '8.x-1.18' project: 'paragraphs' -datestamp: 1705234150 +datestamp: 1723029150 diff --git a/web/modules/paragraphs/modules/paragraphs_library/config/install/paragraphs.paragraphs_type.from_library.yml b/web/modules/paragraphs/modules/paragraphs_library/config/install/paragraphs.paragraphs_type.from_library.yml index b889e4906fc585a4697ccde17f2f160d14935a87..3ddaa2cf0f7baf82af86c89b42e10d41ece3ea04 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/config/install/paragraphs.paragraphs_type.from_library.yml +++ b/web/modules/paragraphs/modules/paragraphs_library/config/install/paragraphs.paragraphs_type.from_library.yml @@ -1,6 +1,9 @@ langcode: en status: true -dependencies: { } +dependencies: + enforced: + module: + - paragraphs_library id: from_library label: 'From library' behavior_plugins: { } diff --git a/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.info.yml b/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.info.yml index 6515d53e23d5103300ba9a4c54fbded6792ab12c..d5a009df23cd94ae9727b31cb6e9e342ba938277 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.info.yml +++ b/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.info.yml @@ -1,7 +1,7 @@ name: Paragraphs Library type: module description: 'Provides a library for reusing paragraphs.' -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^10.2 || ^11 package: Paragraphs configure: paragraphs_library_item.settings dependencies: @@ -11,7 +11,7 @@ dependencies: test_dependencies: - entity_browser:entity_browser -# Information added by Drupal.org packaging script on 2024-01-14 -version: '8.x-1.17' +# Information added by Drupal.org packaging script on 2024-08-07 +version: '8.x-1.18' project: 'paragraphs' -datestamp: 1705234150 +datestamp: 1723029150 diff --git a/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.install b/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.install index 1751ed9f35d929f316552d7edf02921112d06cd0..79e35630bfbf059b1094d2e5df2b7e30c12f13b9 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.install +++ b/web/modules/paragraphs/modules/paragraphs_library/paragraphs_library.install @@ -370,3 +370,19 @@ function paragraphs_library_update_8102() { ->save(); } } + +/** + * Add the paragraphs_library module as dependency to the from_library paragraphs type. + */ +function paragraphs_library_update_8103() { + $config = \Drupal::configFactory()->getEditable('paragraphs.paragraphs_type.from_library'); + if ($config->isNew()) { + return; + } + + $dependencies = $config->get('dependencies') ?? []; + $dependencies['enforced']['module'][] = 'paragraphs_library'; + + $config->set('dependencies', $dependencies); + $config->save(); +} diff --git a/web/modules/paragraphs/modules/paragraphs_library/src/Form/LibraryItemSettingsForm.php b/web/modules/paragraphs/modules/paragraphs_library/src/Form/LibraryItemSettingsForm.php index f395782cdee3ade333ed0742773bf4a4ee26a147..2e3c4a3da37123ec909ad4e8af34af9eef59c28e 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/src/Form/LibraryItemSettingsForm.php +++ b/web/modules/paragraphs/modules/paragraphs_library/src/Form/LibraryItemSettingsForm.php @@ -4,12 +4,55 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Entity\EntityFieldManagerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface; /** * Form for Paragraphs library item settings. */ class LibraryItemSettingsForm extends ConfigFormBase { + /** + * The entity reference selection plugin manager. + * + * @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface + */ + protected $pluginManagerEntityReferenceSelection; + + /** + * The entity field manager. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + + /** + * Constructs a new LibraryItemBaseParagraphOverrideForm object. + * + * @param \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface $plugin_manager_entity_reference_selection + * The selection plugin manager. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager + * The entity field manager. + */ + public function __construct( + SelectionPluginManagerInterface $plugin_manager_entity_reference_selection, + EntityFieldManagerInterface $entity_field_manager + ) { + $this->entityFieldManager = $entity_field_manager; + $this->pluginManagerEntityReferenceSelection = $plugin_manager_entity_reference_selection; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.entity_reference_selection'), + $container->get('entity_field.manager') + ); + } + /** * {@inheritdoc} */ @@ -28,11 +71,64 @@ protected function getEditableConfigNames() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - // This exists to make the field UI pages visible and must not be removed. - $form['account'] = array( - '#markup' => '<p>' . $this->t('There are no settings yet.') . '</p>', - ); + $paragraph_selection_handler = $this->getParagraphSelectionHandler(); + + // Set the form state to match the existing paragraph selection handler + // settings. + $fields = $this->entityFieldManager->getFieldDefinitions('paragraphs_library_item', 'paragraphs_library_item'); + $settings = $fields['paragraphs']->getConfig('paragraphs_library_item')->getSettings(); + if (!empty($settings['handler_settings'])) { + // Since we are building a handler's form, have to move handler settings + // up to the same level as the rest of the config. + $handler_settings = $settings['handler_settings']; + unset($settings['handler_settings']); + $settings = array_merge($settings, $handler_settings); + $paragraph_selection_handler->setConfiguration($settings); + } + + // Build this form using the ParagraphsSelection form. + $form = $paragraph_selection_handler->buildConfigurationForm($form, $form_state); return parent::buildForm($form, $form_state); } + + /** + * Get an instance of the paragraph selection handler. + * + * @return false|\Drupal\paragraphs\Plugin\EntityReferenceSelection\ParagraphSelection + * The paragraph selection handler. + */ + protected function getParagraphSelectionHandler() { + // Get an instance of the ParagraphsSelection handler. + $options = [ + 'target_type' => 'paragraph', + 'handler' => 'default:paragraph', + ]; + return $this->pluginManagerEntityReferenceSelection->getInstance($options); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + + // Get only the values related to the paragraph selection handler form. + $values = $form_state->getValues(); + $paragraph_selection_handler = $this->getParagraphSelectionHandler(); + $paragraph_selection_form = $paragraph_selection_handler->buildConfigurationForm([], $form_state); + $paragraph_selection_form_values = array_intersect_key($values, $paragraph_selection_form); + + // Get existing paragraphs selection settings. + $fields = $this->entityFieldManager->getFieldDefinitions('paragraphs_library_item', 'paragraphs_library_item'); + $paragraphs_config = $fields['paragraphs']->getConfig('paragraphs_library_item'); + $settings = $paragraphs_config->getSettings(); + + // Save the new handler settings. + $settings['handler_settings'] = $paragraph_selection_form_values; + $settings['handler'] = 'default:paragraph'; + $paragraphs_config->setSettings($settings)->save(); + + $this->entityFieldManager->clearCachedFieldDefinitions(); + } + } diff --git a/web/modules/paragraphs/modules/paragraphs_library/tests/src/Functional/ParagraphsLibraryTest.php b/web/modules/paragraphs/modules/paragraphs_library/tests/src/Functional/ParagraphsLibraryTest.php index 198e108df0486b4a18b8dc467a1d3ed797b57ba7..9821ced5cd3fd6aa01499921790ee410f64148d1 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/tests/src/Functional/ParagraphsLibraryTest.php +++ b/web/modules/paragraphs/modules/paragraphs_library/tests/src/Functional/ParagraphsLibraryTest.php @@ -297,12 +297,7 @@ public function testLibraryItems() { $this->assertSession()->buttonExists('Save configuration'); // Assert that users can create fields to $this->clickLink('Manage fields'); - if (version_compare(\Drupal::VERSION, '10.1', '>=')) { - $this->clickLink('Create a new field'); - } - else { - $this->clickLink('Add field'); - } + $this->clickLink('Create a new field'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('plugin does not exist'); $this->drupalGet('admin/config/content'); diff --git a/web/modules/paragraphs/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php b/web/modules/paragraphs/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php index c480f1d1d77b0bb3dd85819493d6e62989bb761e..24e492527733ad79e61b4790f9072470ddd190c9 100644 --- a/web/modules/paragraphs/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php +++ b/web/modules/paragraphs/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php @@ -98,16 +98,9 @@ public function testEntityBrowserWidget() { $this->getSession()->switchToIFrame('entity_browser_iframe_paragraphs_library_items'); $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:1"].form-radio'); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - // Now wait until the button and iframe is gone, wait at least one second - // because the ajax detection does not reliable detect the active ajax - // processing in the iframe. - sleep(1); $this->waitForAjaxToFinish(); $this->submitForm([], 'Save'); // Check that the paragraph was correctly reused. @@ -159,12 +152,8 @@ public function testEntityBrowserWidget() { $this->getSession()->switchToIFrame('entity_browser_iframe_paragraphs_library_items'); $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:2"].form-radio'); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - sleep(1); $this->waitForAjaxToFinish(); // Edit the inside library item after adding it. $this->getSession()->getPage()->pressButton('Edit'); @@ -197,12 +186,8 @@ public function testEntityBrowserWidget() { $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:3"].form-radio'); $this->assertTrue($style_selector->isVisible()); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - sleep(1); $this->waitForAjaxToFinish(); $this->assertSession()->elementContains('css', '.paragraphs-collapsed-description .paragraphs-content-wrapper', 'Inner library item'); $this->submitForm([], 'Save'); diff --git a/web/modules/paragraphs/modules/paragraphs_type_permissions/paragraphs_type_permissions.info.yml b/web/modules/paragraphs/modules/paragraphs_type_permissions/paragraphs_type_permissions.info.yml index efb67c6f98e8e39d61acae68e1a3952323319ad9..95991cc6a7c8885a0d1d59e1933bc191d9601c6e 100644 --- a/web/modules/paragraphs/modules/paragraphs_type_permissions/paragraphs_type_permissions.info.yml +++ b/web/modules/paragraphs/modules/paragraphs_type_permissions/paragraphs_type_permissions.info.yml @@ -1,13 +1,13 @@ name: Paragraphs Type Permissions type: module description: 'Allows users to configure permissions for individual Paragraphs types.' -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^10.2 || ^11 package: Paragraphs dependencies: - paragraphs:paragraphs -# Information added by Drupal.org packaging script on 2024-01-14 -version: '8.x-1.17' +# Information added by Drupal.org packaging script on 2024-08-07 +version: '8.x-1.18' project: 'paragraphs' -datestamp: 1705234150 +datestamp: 1723029150 diff --git a/web/modules/paragraphs/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php b/web/modules/paragraphs/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php index 0ca729f23fd76f29e5b2530550b66236fb49c80e..7854d1fe9243a51236071743178b5f067d16e1b6 100644 --- a/web/modules/paragraphs/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php +++ b/web/modules/paragraphs/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\paragraphs_type_permissions\Functional; +use Drupal\image\Entity\ImageStyle; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; @@ -165,9 +166,12 @@ public function testAnonymousParagraphsTypePermissions() { // Get the node to edit it later. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); + /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */ + $file_url_generator = \Drupal::service('file_url_generator'); + // Get the images data to check for their presence. - $image_text_tag = '/files/styles/large/public/' . date('Y-m') . '/image-test.png?itok='; - $images_tag = '/files/styles/medium/public/' . date('Y-m') . '/image-test_0.png?itok='; + $image_text_tag = $file_url_generator->transformRelative(ImageStyle::load('large')->buildUrl('public://' . date('Y-m') . '/image-test.png')); + $images_tag = $file_url_generator->transformRelative(ImageStyle::load('medium')->buildUrl('public://' . date('Y-m') . '/image-test_0.png')); // Check that all paragraphs are shown for admin user. $this->assertSession()->responseContains($image_text_tag); diff --git a/web/modules/paragraphs/paragraphs.info.yml b/web/modules/paragraphs/paragraphs.info.yml index d5b11d785237d5969d03cbb3e357f1e31c2b525f..ba99d832c1c31d510acaa2951646b56e27a052f4 100644 --- a/web/modules/paragraphs/paragraphs.info.yml +++ b/web/modules/paragraphs/paragraphs.info.yml @@ -1,7 +1,7 @@ name: Paragraphs type: module description: 'Enables the creation of paragraphs entities.' -core_version_requirement: ^9.3 || ^10 +core_version_requirement: ^10.2 || ^11 package: Paragraphs configure: entity.paragraphs_type.collection @@ -16,7 +16,7 @@ test_dependencies: - field_group:field_group - block_field:block_field -# Information added by Drupal.org packaging script on 2024-01-14 -version: '8.x-1.17' +# Information added by Drupal.org packaging script on 2024-08-07 +version: '8.x-1.18' project: 'paragraphs' -datestamp: 1705234150 +datestamp: 1723029150 diff --git a/web/modules/paragraphs/paragraphs.module b/web/modules/paragraphs/paragraphs.module index a783000d3c8a1c8b0e0c64b2c6bb95449f4943fc..885955ce6f911eac8bb1a08a8c1d68d61bc1496e 100644 --- a/web/modules/paragraphs/paragraphs.module +++ b/web/modules/paragraphs/paragraphs.module @@ -127,18 +127,43 @@ function paragraphs_form_entity_form_display_edit_form_alter(&$form, FormStateIn /** * 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) { - if ($form_state->getFormObject()->getEntity()->getType() == 'entity_reference') { +function paragraphs_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { + $field = $form_state->getFormObject()->getEntity(); - if (version_compare(\Drupal::VERSION, '10.2', '>')) { - $selector = 'field_storage[subform][settings][target_type]'; - } - else { - $selector = 'settings[target_type]'; + if (\Drupal::hasService('content_translation.manager')) { + $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') { + // 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. - $form['settings']['paragraph_warning_wrapper'] = [ + $form['field_storage']['subform']['settings']['paragraph_warning_wrapper'] = [ '#type' => 'container', '#states' => [ 'visible' => [ @@ -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) { - - if (version_compare(\Drupal::VERSION, '10.2', '<')) { - return; - } - - // 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+. + // 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'])) { $options['paragraph']['weight'] = -15; $options['paragraph']['category'] = FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY;; @@ -347,6 +327,14 @@ function template_preprocess_paragraph(&$variables) { } $paragraph_type = $variables['elements']['#paragraph']->getParagraphType(); + if (!$paragraph_type) { + \Drupal::logger('paragraphs') + ->critical(t('Unable to load paragraph type %type when displaying paragraph %id'), [ + '%type' => $variables['elements']['#paragraph']->bundle(), + '%id' => $variables['elements']['#paragraph']->id(), + ]); + $paragraph_type = ParagraphsType::create(['id' => $variables['elements']['#paragraph']->bundle()]); + } foreach ($paragraph_type->getEnabledBehaviorPlugins() as $plugin_value) { $plugin_value->preprocess($variables); } @@ -439,13 +427,13 @@ function paragraphs_preprocess_field_multiple_value_form(&$variables) { if (isset($variables['table']['#tabledrag'])) { // Remove the tabledrag. unset($variables['table']['#tabledrag']); - unset($variables['table']['#header'][1]); + unset($variables['table']['#header'][2]); foreach ($variables['table']['#rows'] as $key => $value) { $variables['table']['#rows'][$key]['data'][0]['class'][] = 'paragraph-bullet'; // Restore the removed weight and give access FALSE. - if (isset($value['data'][2])) { - $variables['table']['#rows'][$key]['data'][1]['data']['_weight'] = $value['data'][2]['data']; - unset($variables['table']['#rows'][$key]['data'][2]); + if (isset($value['data'][3])) { + $variables['table']['#rows'][$key]['data'][1]['data']['_weight'] = $value['data'][3]['data']; + unset($variables['table']['#rows'][$key]['data'][3]); $variables['table']['#rows'][$key]['data'][1]['data']['_weight']['#access'] = FALSE; } } diff --git a/web/modules/paragraphs/src/Entity/Paragraph.php b/web/modules/paragraphs/src/Entity/Paragraph.php index 759bd6fe7236a2ccc22e4024edead9649f18c46b..7441e13eae2ca70178760f557acc5907e0724c4a 100644 --- a/web/modules/paragraphs/src/Entity/Paragraph.php +++ b/web/modules/paragraphs/src/Entity/Paragraph.php @@ -125,7 +125,12 @@ public function getParentEntity() { return NULL; } - $parent = \Drupal::entityTypeManager()->getStorage($this->get('parent_type')->value)->load($this->get('parent_id')->value); + $entityTypeManager = \Drupal::entityTypeManager(); + if ($entityTypeManager->hasDefinition($this->get('parent_type')->value)) { + $parent = $entityTypeManager + ->getStorage($this->get('parent_type')->value) + ->load($this->get('parent_id')->value); + } // Return current translation of parent entity, if it exists. if ($parent != NULL && ($parent instanceof TranslatableInterface) && $parent->hasTranslation($this->language()->getId())) { @@ -496,7 +501,7 @@ public function getSummaryItems(array $options = []) { foreach ($referenced_entities as $referenced_entity) { if ($referenced_entity->access('view label')) { // Switch to the entity translation in the current context. - $entity = \Drupal::service('entity.repository')->getTranslationFromContext($referenced_entity, $this->activeLangcode); + $entity = \Drupal::service('entity.repository')->getTranslationFromContext($referenced_entity, $this->language()->getId()); $summary['content'][] = $entity->label(); } } @@ -697,7 +702,7 @@ protected function getNestedSummary($field_name, array $options) { $entity = $item->entity; if ($entity instanceof ParagraphInterface) { // Switch to the entity translation in the current context if exists. - $entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $this->activeLangcode); + $entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $this->language()->getId()); $content_summary_items = $entity->getSummaryItems($options)['content']; $summary_content = array_merge($summary_content, array_values($content_summary_items)); $this->summaryCount++; @@ -751,5 +756,4 @@ public function getTextSummary($field_name, FieldDefinitionInterface $field_defi return $summary; } - } diff --git a/web/modules/paragraphs/src/EventSubscriber/ReplicateFieldSubscriber.php b/web/modules/paragraphs/src/EventSubscriber/ReplicateFieldSubscriber.php index 7602c0b9530ace282fe5261216b2467f914d7ba1..444eb0d755defb36f857ce3ca64b9edc2dfc6719 100644 --- a/web/modules/paragraphs/src/EventSubscriber/ReplicateFieldSubscriber.php +++ b/web/modules/paragraphs/src/EventSubscriber/ReplicateFieldSubscriber.php @@ -38,7 +38,9 @@ public function onClone(ReplicateEntityFieldEvent $event) { $field_item_list = $event->getFieldItemList(); if ($field_item_list->getItemDefinition()->getSetting('target_type') == 'paragraph') { foreach ($field_item_list as $field_item) { - $field_item->entity = $this->replicator->replicateEntity($field_item->entity); + if ($field_item->entity) { + $field_item->entity = $this->replicator->replicateEntity($field_item->entity); + } } } } @@ -46,7 +48,7 @@ public function onClone(ReplicateEntityFieldEvent $event) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events[ReplicatorEvents::replicateEntityField('entity_reference_revisions')][] = 'onClone'; return $events; } diff --git a/web/modules/paragraphs/src/Feeds/Target/Paragraphs.php b/web/modules/paragraphs/src/Feeds/Target/Paragraphs.php index e025ad8628bc1dc3d14eb32ee81d301e18cdb39a..7d126ef74f099ed8581a56fbeb8bcaae8797d2d0 100644 --- a/web/modules/paragraphs/src/Feeds/Target/Paragraphs.php +++ b/web/modules/paragraphs/src/Feeds/Target/Paragraphs.php @@ -8,6 +8,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\feeds\Feeds\Target\Text; use Drupal\feeds\Plugin\Type\Target\ConfigurableTargetInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Feeds target plugin for Paragraphs fields. @@ -15,7 +16,6 @@ * @FeedsTarget( * id = "paragraphs", * field_types = {"entity_reference_revisions"}, - * arguments = {"@entity_type.manager", "@current_user"} * ) */ class Paragraphs extends Text implements ConfigurableTargetInterface { @@ -51,6 +51,19 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi $this->fieldConfigStorage = $entity_type_manager->getStorage('field_config'); } + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('current_user'), + ); + } + /** * {@inheritdoc} */ @@ -104,18 +117,23 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function getSummary() { - $summary = $this->t('Not yet configured.'); + $summary = parent::getSummary(); + $paragraphs_type_id = $this->configuration['paragraphs_type']; $paragraph_field_name = $this->configuration['paragraph_field']; if ($paragraphs_type_id && $paragraphs_type = $this->paragraphsTypeStorage->load($paragraphs_type_id)) { if ($paragraph_field_name && $paragraph_field = $this->fieldConfigStorage->load('paragraph.' . $paragraphs_type_id . '.' . $paragraph_field_name)) { - $summary = $this->t('Using the %field field on a %type paragraph.', [ + $summary[] = $this->t('Using the %field field on a %type paragraph.', [ '%field' => $paragraph_field->label(), '%type' => $paragraphs_type->label(), ]); } } - return $summary . '<br>' . parent::getSummary(); + else { + $summary[] = $this->t('Not yet configured.'); + } + + return $summary; } /** diff --git a/web/modules/paragraphs/src/Form/ParagraphsTypeForm.php b/web/modules/paragraphs/src/Form/ParagraphsTypeForm.php index dee8c7a691d6cf19c7ff10180e0cb4b11267d2aa..e7796d95ac32737bd98012f02d5e7ce36ea3b622 100644 --- a/web/modules/paragraphs/src/Form/ParagraphsTypeForm.php +++ b/web/modules/paragraphs/src/Form/ParagraphsTypeForm.php @@ -98,7 +98,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'managed_file', '#upload_location' => ParagraphsTypeInterface::ICON_UPLOAD_LOCATION, '#upload_validators' => [ - 'file_validate_extensions' => ['png jpg svg'], + 'FileExtension' => ['extensions' => 'png jpg svg'], ], ]; diff --git a/web/modules/paragraphs/src/ParagraphViewBuilder.php b/web/modules/paragraphs/src/ParagraphViewBuilder.php index bca9b7175dbc593f31b8699cbb993cf30ebae265..c279a300b23b0bbac382a26f0670e4fdb3f7d737 100644 --- a/web/modules/paragraphs/src/ParagraphViewBuilder.php +++ b/web/modules/paragraphs/src/ParagraphViewBuilder.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay; use Drupal\Core\Entity\EntityViewBuilder; use Drupal\Core\Render\Element; +use Drupal\paragraphs\Entity\ParagraphsType; /** * Render controller for paragraphs. @@ -22,6 +23,9 @@ public function buildMultiple(array $build_list) { $build = $build_list[$key]; $display = EntityViewDisplay::load('paragraph.' . $build['#paragraph']->bundle() . '.' . $build['#view_mode']) ?: EntityViewDisplay::load('paragraph.' . $build['#paragraph']->bundle() . '.default'); $paragraph_type = $build['#paragraph']->getParagraphType(); + if (!$paragraph_type) { + $paragraph_type = ParagraphsType::create(['id' => $build['#paragraph']->bundle()]); + } // In case we use paragraphs type with no fields the EntityViewDisplay // might not be available yet. diff --git a/web/modules/paragraphs/src/Plugin/EntityReferenceSelection/ParagraphSelection.php b/web/modules/paragraphs/src/Plugin/EntityReferenceSelection/ParagraphSelection.php index 5564a48803a97db0ccec169ac53cee6cdba9b4b1..fb4a04d97c6bfb43e204a309da14b132998956cf 100644 --- a/web/modules/paragraphs/src/Plugin/EntityReferenceSelection/ParagraphSelection.php +++ b/web/modules/paragraphs/src/Plugin/EntityReferenceSelection/ParagraphSelection.php @@ -47,6 +47,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $bundle_options_simple[$bundle_name] = $bundle_info['label']; $bundle_options[$bundle_name] = array( 'label' => $bundle_info['label'], + 'description' => $this->entityTypeManager->getStorage('paragraphs_type') + ->load($bundle_name)?->getDescription(), 'enabled' => $this->configuration['target_bundles_drag_drop'][$bundle_name]['enabled'] ?? FALSE, 'weight' => $this->configuration['target_bundles_drag_drop'][$bundle_name]['weight'] ?? $weight, ); @@ -78,6 +80,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'table', '#header' => [ $this->t('Type'), + $this->t('Description'), $this->t('Weight'), ], '#attributes' => [ @@ -114,6 +117,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $bundle_info['enabled'], ); + $form['target_bundles_drag_drop'][$bundle_name]['description'] = [ + '#markup' => $bundle_info['description'], + ]; + $form['target_bundles_drag_drop'][$bundle_name]['weight'] = array( '#type' => 'weight', '#default_value' => (int) $bundle_info['weight'], diff --git a/web/modules/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/web/modules/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php index aa2b7070c2c215733c5e465463d35af0b1fb2ba2..005aeda8fdaa7fb33750aff799b479fb03b28437 100644 --- a/web/modules/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php +++ b/web/modules/paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php @@ -1314,7 +1314,7 @@ public function multipleElementValidate(array $elements, FormStateInterface $for public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); $widget_state = static::getWidgetState($form['#parents'], $field_name, $form_state); - $element = NestedArray::getValue($form_state->getCompleteForm(), $widget_state['array_parents']); + $element = NestedArray::getValue($form_state->getCompleteForm(), $widget_state['array_parents'] ?? []); foreach ($values as &$item) { if (isset($widget_state['paragraphs'][$item['_original_delta']]['entity']) diff --git a/web/modules/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php b/web/modules/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php index efd9c4452391e3c9008d2d342a97b3cb77d5d47b..bf8633a39e19700a5466af2ad19dec5f774af0d4 100644 --- a/web/modules/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php +++ b/web/modules/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php @@ -6,6 +6,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Entity\EntityFormDisplay; +use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldFilteredMarkup; @@ -18,8 +19,10 @@ use Drupal\Core\TypedData\TranslationStatusInterface; use Drupal\field_group\FormatterHelper; use Drupal\paragraphs\Entity\Paragraph; +use Drupal\paragraphs\Entity\ParagraphsType; use Drupal\paragraphs\ParagraphInterface; use Drupal\paragraphs\Plugin\EntityReferenceSelection\ParagraphSelection; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -94,6 +97,13 @@ class ParagraphsWidget extends WidgetBase { */ protected $accessOptions = NULL; + /** + * The entity field manager service. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + /** * Constructs a ParagraphsWidget object. * @@ -107,17 +117,35 @@ class ParagraphsWidget extends WidgetBase { * The widget settings. * @param array $third_party_settings * Any third party settings. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager + * The entity field manager service. */ - public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings) { + public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityFieldManagerInterface $entity_field_manager) { // Modify settings that were set before https://www.drupal.org/node/2896115. if(isset($settings['edit_mode']) && $settings['edit_mode'] === 'preview') { $settings['edit_mode'] = 'closed'; $settings['closed_mode'] = 'preview'; } + $this->entityFieldManager = $entity_field_manager; + parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings); } + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $plugin_id, + $plugin_definition, + $configuration['field_definition'], + $configuration['settings'], + $configuration['third_party_settings'], + $container->get('entity_field.manager'), + ); + } + /** * {@inheritdoc} */ @@ -2530,7 +2558,9 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) { // Validation errors might be a about a specific (behavior) form element // attempt to find a matching element. - if (!empty($error->arrayPropertyPath) && $sub_element = NestedArray::getValue($element, $error->arrayPropertyPath)) { + $property_path_array = explode('.', $error->getPropertyPath()); + array_shift($property_path_array); + if (!empty($property_path_array) && $sub_element = NestedArray::getValue($element, $property_path_array)) { return $sub_element; } return $element; @@ -2565,7 +2595,7 @@ public function multipleElementValidate(array $elements, FormStateInterface $for public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); $widget_state = static::getWidgetState($form['#parents'], $field_name, $form_state); - $element = NestedArray::getValue($form_state->getCompleteForm(), $widget_state['array_parents']); + $element = NestedArray::getValue($form_state->getCompleteForm(), $widget_state['array_parents'] ?? []); if (!empty($widget_state['dragdrop'])) { $path = array_merge($form['#parents'], array($field_name)); @@ -2653,7 +2683,7 @@ public function massageFormValues(array $values, array $form, FormStateInterface continue; } - $form_state->setError($element[$item['_original_delta']], $this->t('Validation error on collapsed paragraph @path: @message', ['@path' => $violation->getPropertyPath(), '@message' => $violation->getMessage()])); + $this->massageCollapsedParagraphsErrorMessages($form, $form_state, $element, $item, $violation); } } } @@ -3107,4 +3137,61 @@ protected function isFeatureEnabled($feature) { return FALSE; } + /** + * Improve validation error messages by including additional labels. + * + * This will convert an error message of type: + * "Text field is required." + * into something like: + * "Error in field Content #1 (Hero): Text field is required." + * where "Content" is the top-level paragraph field label, "Hero" is the + * paragraph type label, and "1" is the position of the paragraph in the + * field (delta + 1). + * + * @param array $form + * The form array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state object. + * @param array $element + * Element with error. + * @param array $item + * Sequence of the item. + * @param \Symfony\Component\Validator\ConstraintViolationInterface $violation + * Violation of the field. + */ + protected function massageCollapsedParagraphsErrorMessages(array $form, FormStateInterface $form_state, $element, $item, $violation) { + $field_name = $this->fieldDefinition->getName(); + $field_label = $form[$field_name]['widget']['#title'] ?? FALSE; + $delta = $item['_original_delta']; + $paragraph_type = $form[$field_name]['widget'][$delta]['#paragraph_type'] ?? FALSE; + if ($field_label && $paragraph_type) { + $paragraph_type_label = ParagraphsType::load($paragraph_type)->label(); + $property_path = $violation->getPropertyPath(); + $property_path = explode('.', $property_path)[0]; + + $fields = $this->entityFieldManager->getFieldDefinitions('paragraph', $paragraph_type); + if (isset($fields[$property_path])) { + $new_message = $this->t('Error in field %field #@position (@bundle), %subfield : @message', [ + '%field' => $field_label, + '@position' => $delta + 1, + '@bundle' => $paragraph_type_label, + '%subfield' => $fields[$property_path]->getLabel(), + '@message' => $violation->getMessage(), + ]); + } + else { + $new_message = $this->t('Error in field %field #@position (@bundle): @message', [ + '%field' => $field_label, + '@position' => $delta + 1, + '@bundle' => $paragraph_type_label, + '@message' => $violation->getMessage(), + ]); + } + + $form_state->setError($element[$item['_original_delta']], $new_message); + } else { + $form_state->setError($element[$item['_original_delta']], $this->t('Validation error on collapsed paragraph @path: @message', ['@path' => $violation->getPropertyPath(), '@message' => $violation->getMessage()])); + } + } + } diff --git a/web/modules/paragraphs/src/Plugin/migrate/field/FieldCollection.php b/web/modules/paragraphs/src/Plugin/migrate/field/FieldCollection.php index 73d8b00617e4afabe4c5713da1299b62deba47f1..e9e9c0b101f65d0f4bcdd92592afb279b090f62f 100644 --- a/web/modules/paragraphs/src/Plugin/migrate/field/FieldCollection.php +++ b/web/modules/paragraphs/src/Plugin/migrate/field/FieldCollection.php @@ -25,6 +25,11 @@ class FieldCollection extends FieldPluginBase { */ const FIELD_COLLECTION_PREFIX_LENGTH = 6; + /** + * Recursion counter. + */ + static int $recursionCounter = 0; + /** * {@inheritdoc} */ @@ -65,6 +70,15 @@ public function defineValueProcessPipeline(MigrationInterface $migration, $field ]; $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. $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); @@ -76,6 +90,8 @@ public function defineValueProcessPipeline(MigrationInterface $migration, $field $dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [$migration_rev_dependency])); $migration->set('migration_dependencies', $dependencies); } + + static::$recursionCounter--; } /** diff --git a/web/modules/paragraphs/src/Plugin/migrate/field/Paragraphs.php b/web/modules/paragraphs/src/Plugin/migrate/field/Paragraphs.php index 6c42aa497c8e89b173662ae95b5d52acababe379..f81e6a77cca08e696d7f1b1eabd3251dc95a31f8 100644 --- a/web/modules/paragraphs/src/Plugin/migrate/field/Paragraphs.php +++ b/web/modules/paragraphs/src/Plugin/migrate/field/Paragraphs.php @@ -20,6 +20,11 @@ */ class Paragraphs extends FieldPluginBase { + /** + * Recursion counter. + */ + static int $recursionCounter = 0; + /** * {@inheritdoc} */ @@ -67,6 +72,15 @@ public function defineValueProcessPipeline(MigrationInterface $migration, $field // @todo: This is a great example why we should consider derive paragraph // migrations based on parent entity type (and bundle). 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['required'] = array_unique(array_merge(array_values($dependencies['required']), [ 'd7_paragraphs', @@ -79,6 +93,8 @@ public function defineValueProcessPipeline(MigrationInterface $migration, $field ])); $migration->set('migration_dependencies', $dependencies); } + + static::$recursionCounter--; } } diff --git a/web/modules/paragraphs/tests/modules/paragraphs_test/paragraphs_test.info.yml b/web/modules/paragraphs/tests/modules/paragraphs_test/paragraphs_test.info.yml index 483f2438b7e42f3cf59f4a3dc3c69fea75325d6d..aa0c2cfc7d7ea6995b2a79444199cd6e46e781f6 100644 --- a/web/modules/paragraphs/tests/modules/paragraphs_test/paragraphs_test.info.yml +++ b/web/modules/paragraphs/tests/modules/paragraphs_test/paragraphs_test.info.yml @@ -7,7 +7,7 @@ package: Testing dependencies: - paragraphs:paragraphs -# Information added by Drupal.org packaging script on 2024-01-14 -version: '8.x-1.17' +# Information added by Drupal.org packaging script on 2024-08-07 +version: '8.x-1.18' project: 'paragraphs' -datestamp: 1705234150 +datestamp: 1723029150 diff --git a/web/modules/paragraphs/tests/src/Functional/Feeds/Target/ParagraphsTest.php b/web/modules/paragraphs/tests/src/Functional/Feeds/Target/ParagraphsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fcc67f1cc4afe76d33391efe5fed1cfd07f577c5 --- /dev/null +++ b/web/modules/paragraphs/tests/src/Functional/Feeds/Target/ParagraphsTest.php @@ -0,0 +1,105 @@ +<?php + +namespace Drupal\Tests\paragraphs\Functional\Feeds\Target; + +use Drupal\Tests\feeds\Functional\FeedsBrowserTestBase; +use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait; + +/** + * Tests the FeedsTarget plugin "paragraphs" in the UI. + * + * @group paragraphs + */ +class ParagraphsTest extends FeedsBrowserTestBase { + + use ParagraphsTestBaseTrait; + + /** + * Modules to enable. + * + * @var string[] + */ + protected static $modules = [ + 'feeds', + 'node', + 'paragraphs', + ]; + + /** + * The feed type entity. + * + * @var \Drupal\feeds\Entity\FeedType + */ + protected $feedType; + + /** + * {@inheritdoc} + */ + public function setUp(): void { + parent::setUp(); + + // Add a Paragraph field to the article content type. + $this->addParagraphsField('article', 'field_paragraphs', 'node'); + + $this->addParagraphsType('test_paragraph'); + $this->addFieldtoParagraphType('test_paragraph', 'field_text', 'text'); + + // Create a feed type. + $this->feedType = $this->createFeedType(); + } + + /** + * Tests adding mapping to a paragraph field. + */ + public function testAddMapping() { + $this->drupalGet('admin/structure/feeds/manage/' . $this->feedType->id() . '/mapping'); + $edit = [ + 'add_target' => 'field_paragraphs', + ]; + $this->submitForm($edit, 'Save'); + + // And try to configure it. + $edit = []; + $this->submitForm($edit, 'target-settings-2'); + + // Select paragraphs type. + $edit = [ + 'mappings[2][settings][paragraphs_type]' => 'test_paragraph', + ]; + $this->submitForm($edit, 'target-save-2'); + + // Configure again to select field. + $edit = []; + $this->submitForm($edit, 'target-settings-2'); + + // Select paragraphs field. + $edit = [ + 'mappings[2][settings][paragraph_field]' => 'field_text', + ]; + $this->submitForm($edit, 'target-save-2'); + + // Set a source and save mappings. + $edit = [ + 'mappings[2][map][value][select]' => 'content', + ]; + $this->submitForm($edit, 'Save'); + + // Assert expected mapping configuration. + $this->feedType = $this->reloadEntity($this->feedType); + $saved_mappings = $this->feedType->getMappings(); + $expected_mapping = [ + 'target' => 'field_paragraphs', + 'map' => [ + 'value' => 'content', + ], + 'settings' => [ + 'paragraphs_type' => 'test_paragraph', + 'paragraph_field' => 'field_text', + 'language' => '', + 'format' => 'plain_text', + ], + ]; + $this->assertEquals($expected_mapping, $saved_mappings[2]); + } + +} diff --git a/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php b/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php index 2a5304e9ed5dfe55be4a2b8720fa2d6dd4692bac..9354dcd7018ef3e4f516326a9277620c259ad752 100644 --- a/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php +++ b/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php @@ -13,6 +13,11 @@ */ class MigrateUiParagraphsTest extends MigrateUiParagraphsTestBase { + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + use ParagraphsNodeMigrationAssertionsTrait; /** @@ -35,7 +40,7 @@ public function testParagraphsMigrate($node_migrate_type_classic) { * @return bool[][] * Classic node migration type. */ - public function providerParagraphsMigrate() { + public static function providerParagraphsMigrate() { return [ ['node_migrate_type_classic' => TRUE], ['node_migrate_type_classic' => FALSE], diff --git a/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php b/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php index b9096e704cd8ca0f1cf4e4f2f3ead0600e73d098..d7ded5c874f9dc157dc9fca94737ac38d59ccd54 100644 --- a/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php +++ b/web/modules/paragraphs/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php @@ -405,7 +405,7 @@ protected function assertMigrateUpgradeViaUi() { $session = $this->assertSession(); $session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal'); - $this->submitForm([], $this->t('Continue')); + $this->submitForm([], 'Continue'); $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); $driver = $connection_options['driver']; @@ -420,6 +420,7 @@ protected function assertMigrateUpgradeViaUi() { $form = $drivers[$driver]->getInstallTasks()->getFormOptions($connection_options); } else { + // @phpstan-ignore-next-line $drivers = drupal_get_database_types(); $form = $drivers[$driver]->getFormOptions($connection_options); } @@ -437,17 +438,17 @@ protected function assertMigrateUpgradeViaUi() { } $edits = $this->translatePostValues($edit); - $this->submitForm($edits, $this->t('Review upgrade')); + $this->submitForm($edits, 'Review upgrade'); $session->pageTextNotContains('Resolve all issues below to continue the upgrade.'); // ID conflict form. - $session->buttonExists($this->t('I acknowledge I may lose data. Continue anyway.')); - $this->submitForm([], $this->t('I acknowledge I may lose data. Continue anyway.')); + $session->buttonExists('I acknowledge I may lose data. Continue anyway.'); + $this->submitForm([], 'I acknowledge I may lose data. Continue anyway.'); $session->statusCodeEquals(200); // Perform the upgrade. - $this->submitForm([], $this->t('Perform upgrade')); - $session->pageTextContains($this->t('Congratulations, you upgraded Drupal!')); + $this->submitForm([], 'Perform upgrade'); + $session->pageTextContains('Congratulations, you upgraded Drupal!'); // Have to reset all the statics after migration to ensure entities are // loadable. diff --git a/web/modules/paragraphs/tests/src/Functional/ParagraphsUiTest.php b/web/modules/paragraphs/tests/src/Functional/ParagraphsUiTest.php index 1a5fe79bcb4fbc454f4154c6654167757143c840..25cf8e9244fde057fb3fd595931ec349e20913c3 100644 --- a/web/modules/paragraphs/tests/src/Functional/ParagraphsUiTest.php +++ b/web/modules/paragraphs/tests/src/Functional/ParagraphsUiTest.php @@ -107,20 +107,17 @@ public function testDefaultWidget() { ], 'Save and manage fields'); // Add a new paragraphs field to the content type. - if (version_compare(\Drupal::VERSION, '10.1', '>=')) { - $this->clickLink('Create a new field'); - } - else { - $this->clickLink('Add field'); + $this->clickLink('Create a new field'); + + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); } - $this->submitForm([ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', + $edit = [ 'label' => 'Paragraph', 'field_name' => 'paragraph', - ], $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); - if (!$this->coreVersion('10.2')) { - $this->submitForm([], 'Save field settings'); - } + ]; + $this->submitForm($edit, 'Continue'); $this->submitForm([], 'Save settings'); // Visit the "Manage form display" page of the new content type. diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php index 7a6a7132ba588b7075e5c78d5577e6a4e64314b7..e556748ec9bca8045df0fe63bbef13ba60de181b 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php @@ -101,20 +101,11 @@ public function testParagraphAccessCheck() { $role->save(); // Set field_images from demo to private file storage. - if ($this->coreVersion('10.2')) { - $edit = array( - 'field_storage[subform][settings][uri_scheme]' => 'private', - ); - $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); - $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'); - } + $edit = array( + 'field_storage[subform][settings][uri_scheme]' => 'private', + ); + $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); + $this->submitForm($edit, 'Save settings'); // Set the form display to legacy. $form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default') diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php index 57626cf41ad7439c507708f9a6b6504bbf0b0dda..882e65e364cab8bea215e0ed1ebe38219c22c895 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php @@ -145,15 +145,15 @@ public function testParagraphsCreation() { $this->drupalGet('admin/structure/paragraphs_type'); $this->assertSession()->pageTextContains('There are no Paragraphs types yet.'); $this->drupalGet('admin/structure/types/manage/paragraphs/fields/add-field'); + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); + } $edit = [ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', 'label' => 'Paragraph', 'field_name' => 'paragraph', ]; - $this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); - if (!$this->coreVersion('10.2')) { - $this->submitForm([], 'Save field settings'); - } + $this->submitForm($edit, 'Continue'); $this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add'); $this->clickLink('here'); @@ -438,15 +438,8 @@ public function testParagraphsCreation() { $this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.'); // Set the fields as not required. - if ($this->coreVersion('10.2')) { - $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); - $this->submitForm(['required' => FALSE], 'Save'); - } - else { - $this->drupalGet('admin/structure/types/manage/article/fields'); - $this->clickLink('Edit'); - $this->submitForm(['required' => FALSE], 'Save settings'); - } + $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); + $this->submitForm(['required' => FALSE], 'Save'); // Set the Paragraph field edit mode to 'Closed'. $this->drupalGet('admin/structure/types/manage/article/form-display'); @@ -486,7 +479,7 @@ public function testParagraphsCreation() { // Assert the validation error message. $this->assertSession()->pageTextContains('The referenced entity (node: 4) does not exist'); // Triggering unrelated button, assert that error message is still present. - $this->submitForm([], 'Add another item'); + $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('The referenced entity (node: 4) does not exist'); $this->assertSession()->pageTextContains('Entity reference (value 1) field is required.'); // Try to collapse with an invalid reference. @@ -494,7 +487,7 @@ public function testParagraphsCreation() { // Paragraph should be still in edit mode. $this->assertSession()->fieldExists('field_paragraphs[0][subform][field_entity_reference][0][target_id]'); $this->assertSession()->fieldExists('field_paragraphs[0][subform][field_entity_reference][1][target_id]'); - $this->submitForm([], 'Add another item'); + $this->submitForm([], 'Save'); // Assert the validation message. $this->assertSession()->pageTextMatches('/There are no (entities|content items) matching "foo"./'); // Attempt to remove the Paragraph. diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php index f1a65dacd4d59e1e1143bbb0c426b849fd69039a..61bd277103eaeca48ebb1e5d5c25d856ffc1e993 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php @@ -125,27 +125,16 @@ public function testContentTranslationForm() { // Check a not paragraphs translatable field does not display the message. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field'); - if ($this->coreVersion('10.2')) { - $selected_group = [ - 'new_storage_type' => 'reference', - ]; - $this->submitForm($selected_group, 'Change field group'); - $edit = [ - 'group_field_options_wrapper' => 'field_ui:entity_reference:node', - 'label' => 'new_no_field_paragraphs', - 'field_name' => 'new_no_field_paragraphs', - ]; - $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'); - } + $selected_group = [ + 'new_storage_type' => 'reference', + ]; + $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); + $edit = [ + 'group_field_options_wrapper' => 'field_ui:entity_reference:node', + 'label' => 'new_no_field_paragraphs', + 'field_name' => 'new_no_field_paragraphs', + ]; + $this->submitForm($edit, 'Continue'); $this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.'); $this->assertSession()->responseNotContains('<div class="messages messages--warning'); } diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsInlineEntityFormTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsInlineEntityFormTest.php index de30175ce974b1323dd99449b62a1bfb1bd46e95..e17e038a0810c314906deac6f124f92787055e19 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsInlineEntityFormTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsInlineEntityFormTest.php @@ -93,21 +93,11 @@ public function testParagraphsIEFChangeOrder() { ]); // Set cardinality explicit to -1. - if ($this->coreVersion('10.2')) { - $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); - $edit = [ - 'field_storage[subform][cardinality]' => '-1', - ]; - $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'); - } + $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); + $edit = [ + 'field_storage[subform][cardinality]' => '-1', + ]; + $this->submitForm($edit, 'Save settings'); // Enable IEF simple widget. $this->drupalGet('admin/structure/paragraphs_type/simple/form-display'); diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php index 96f26aba78b8fe5ca4e8810829f7b835eb412ab6..c5f1a3f5517929f8f2bf52520f55c30b573a902e 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php @@ -103,20 +103,11 @@ public function testParagraphAccessCheck() { $role->save(); // Set field_images from demo to private file storage. - if ($this->coreVersion('10.2')) { - $edit = array( - 'field_storage[subform][settings][uri_scheme]' => 'private', - ); - $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); - $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'); - } + $edit = array( + 'field_storage[subform][settings][uri_scheme]' => 'private', + ); + $this->drupalGet('admin/structure/paragraphs_type/images/fields/paragraph.images.field_images_demo'); + $this->submitForm($edit, 'Save settings'); // Use the stable widget. $form_display = EntityFormDisplay::load('node.paragraphed_content_demo.default') diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php index e695eab2e81ab508154699da1469e0775de2002f..139b373219d33b103f8ca1848f06c06dd7e6e020 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php @@ -148,15 +148,15 @@ public function testParagraphsCreation() { $this->drupalGet('admin/structure/paragraphs_type'); $this->assertSession()->pageTextContains('There are no Paragraphs types yet.'); $this->drupalGet('admin/structure/types/manage/paragraphs/fields/add-field'); + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); + } $edit = [ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', 'label' => 'Paragraph', 'field_name' => 'paragraph', ]; - $this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); - if (!$this->coreVersion('10.2')) { - $this->submitForm([], 'Save field settings'); - } + $this->submitForm($edit, 'Continue'); $this->assertSession()->linkByHrefExists('admin/structure/paragraphs_type/add'); $this->clickLink('here'); @@ -443,15 +443,8 @@ public function testParagraphsCreation() { $this->assertSession()->pageTextNotContains('This entity (paragraph: ) cannot be referenced.'); // Set the fields as not required. - if ($this->coreVersion('10.2')) { - $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); - $this->submitForm(['required' => FALSE], 'Save'); - } - else { - $this->drupalGet('admin/structure/types/manage/article/fields'); - $this->clickLink('Edit'); - $this->submitForm(['required' => FALSE], 'Save settings'); - } + $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); + $this->submitForm(['required' => FALSE], 'Save'); // Set the Paragraph field edit mode to "Closed" and the closed mode to // "Summary". @@ -496,7 +489,7 @@ public function testParagraphsCreation() { $this->assertSession()->pageTextNotContains('The referenced entity (node: ' . $node->id() . ') does not exist.'); $this->assertSession()->fieldNotExists('field_paragraphs[1][subform][field_entity_reference][0][target_id]'); $this->submitForm([], 'Save'); - $this->assertSession()->pageTextContains('Validation error on collapsed paragraph field_entity_reference.0.target_id: The referenced entity (node: ' . $node->id() . ') does not exist.'); + $this->assertSession()->pageTextContains('Error in field field_paragraphs #1 (node_test), Entity reference : The referenced entity (node: ' . $node->id() . ') does not exist.'); // Attempt to edit the Paragraph. $this->submitForm([], 'field_paragraphs_0_edit'); diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php index 825c4039f2bd148b507966d39e1a7671b0cdbf74..a95e2e2f6d80637e61786835d954a10d4e7cdc85 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php @@ -124,29 +124,17 @@ public function testContentTranslationForm() { $this->assertSession()->responseContains('<div class="messages messages--error'); // 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'); - $selected_group = [ - 'new_storage_type' => 'reference', - ]; - $this->submitForm($selected_group, 'Change field group'); - $edit = [ - 'group_field_options_wrapper' => 'field_ui:entity_reference:node', - 'label' => 'new_no_field_paragraphs', - 'field_name' => 'new_no_field_paragraphs', - ]; - $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->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field'); + $selected_group = [ + 'new_storage_type' => 'reference', + ]; + $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); + $edit = [ + 'group_field_options_wrapper' => 'field_ui:entity_reference:node', + 'label' => 'new_no_field_paragraphs', + 'field_name' => 'new_no_field_paragraphs', + ]; + $this->submitForm($edit, 'Continue'); $this->assertSession()->pageTextNotContains('Paragraphs fields do not support translation.'); $this->assertSession()->responseNotContains('<div class="messages messages--warning'); } diff --git a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsInlineEntityFormTest.php b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsInlineEntityFormTest.php index fdfe8b083e0737a2da7592d4d766811fa2a51c1d..44aab31418e0637b985d1cdf8dfbce8837141e4f 100644 --- a/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsInlineEntityFormTest.php +++ b/web/modules/paragraphs/tests/src/Functional/WidgetStable/ParagraphsInlineEntityFormTest.php @@ -101,21 +101,11 @@ public function testParagraphsIEFChangeOrder() { ]); // Set cardinality explicit to -1. - if ($this->coreVersion('10.2')) { - $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); - $edit = [ - 'field_storage[subform][cardinality]' => '-1', - ]; - $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'); - } + $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs'); + $edit = [ + 'field_storage[subform][cardinality]' => '-1', + ]; + $this->submitForm($edit, 'Save settings'); // Enable IEF simple widget. $this->drupalGet('admin/structure/paragraphs_type/simple/form-display'); diff --git a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php index 72533347ab23d4f7a0ba8b193439b75e175ad0a6..781d5878006eaafc3b1e948bb91d69a458de9b21 100644 --- a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php +++ b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php @@ -84,46 +84,35 @@ public function testAddWidgetButton() { // Add a text field to the text_paragraph type. $this->drupalGet('admin/structure/paragraphs_type/' . $paragraph_type . '/fields/add-field'); - if ($this->coreVersion('10.2')) { - $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); - $page->selectFieldOption('group_field_options_wrapper', 'text_long'); + $page->selectFieldOption('new_storage_type', 'formatted_text'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); } else { - $page->selectFieldOption('new_storage_type', 'text_long'); + $this->assertSession()->waitForElementVisible('css', '#text_long'); } + $page->selectFieldOption('group_field_options_wrapper', 'text_long'); $page->fillField('label', 'Text'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'text'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); // Create paragraph type Nested test. $this->addParagraphsType('nested_test'); $this->drupalGet('/admin/structure/paragraphs_type/nested_test/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'Paragraphs'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'paragraphs'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); // Set the settings for the field in the nested paragraph. $component = [ @@ -156,7 +145,6 @@ public function testAddWidgetButton() { // Find the add button in the nested paragraph with xpath. $element = $this->xpath('//div[contains(@class, "form-item")]/div/div/div[contains(@class, "paragraph-type-add-modal")]/input'); $element[0]->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); // Add a text inside the nested paragraph. $page = $this->getSession()->getPage(); @@ -228,37 +216,30 @@ public function testModalAddWidgetDelta() { // Add a text field to the text_paragraph type. $this->drupalGet('admin/structure/paragraphs_type/test_1/fields/add-field'); - if ($this->coreVersion('10.2')) { - $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); - $page->selectFieldOption('group_field_options_wrapper', 'text_long'); + $page->selectFieldOption('new_storage_type', 'formatted_text'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); } else { - $page->selectFieldOption('new_storage_type', 'text_long'); + $this->assertSession()->waitForElementVisible('css', '#text_long'); } + $page->selectFieldOption('group_field_options_wrapper', 'text_long'); $page->fillField('label', 'Text'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'text_1'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); $this->drupalGet('admin/structure/paragraphs_type/test_2/fields/add-field'); - if ($this->coreVersion('10.2')) { - $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); - $page->selectFieldOption('group_field_options_wrapper', 'text_long'); + $page->selectFieldOption('new_storage_type', 'formatted_text'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); } else { - $page->selectFieldOption('new_storage_type', 'text_long'); + $this->assertSession()->waitForElementVisible('css', '#text_long'); } + $page->selectFieldOption('group_field_options_wrapper', 'text_long'); $page->fillField('label', 'Text'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); @@ -274,46 +255,35 @@ public function testModalAddWidgetDelta() { } $this->drupalGet('admin/structure/paragraphs_type/test_3/fields/add-field'); - if ($this->coreVersion('10.2')) { - $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); - $page->selectFieldOption('group_field_options_wrapper', 'text_long'); + $page->selectFieldOption('new_storage_type', 'formatted_text'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); } else { - $page->selectFieldOption('new_storage_type', 'text_long'); + $this->assertSession()->waitForElementVisible('css', '#text_long'); } + $page->selectFieldOption('group_field_options_wrapper', 'text_long'); $page->fillField('label', 'Text'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'test_3'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); // Create paragraph type Nested test. $this->addParagraphsType('test_nested'); $this->drupalGet('/admin/structure/paragraphs_type/test_nested/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'Paragraphs'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'paragraphs'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); // Set the settings for the field in the nested paragraph. $component = [ @@ -351,7 +321,6 @@ public function testModalAddWidgetDelta() { $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val('')"); for ($i = 1; $i <= 2; $i++) { $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_' . $i . '")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); } @@ -364,7 +333,6 @@ public function testModalAddWidgetDelta() { // Add new paragraph to 1st position - set delta to 0 for base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(0)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -376,7 +344,6 @@ public function testModalAddWidgetDelta() { // Add new paragraph to 3rd position - set delta to 2 for base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(2)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -388,7 +355,6 @@ public function testModalAddWidgetDelta() { // Add new paragraph to last position - using really big delta. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(1000)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -400,7 +366,6 @@ public function testModalAddWidgetDelta() { // Clear delta base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val('')"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -438,35 +403,30 @@ public function testModalAddWidgetDelta() { // Add paragraph in nested to have initial state for adding positions. $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to first position. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(0)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to 2nd position - using float value for index. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(1.1111)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to first position - using negative index. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(-100)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to last position - using some text as position. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val('some_text')"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); diff --git a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php index b0fc08dd8a8e4522a2c285e315f1f29ea1f1dd1c..d0f6df6e2913fb8304ff9e1f797fdf4188e5b695 100644 --- a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php +++ b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php @@ -90,27 +90,18 @@ public function testAddParagraphAboveButton() { $this->addParagraphsType('text'); // Add a text field to the text_paragraph type. $this->drupalGet('admin/structure/paragraphs_type/text/fields/add-field'); - if ($this->coreVersion('10.2')) { - $page->selectFieldOption('new_storage_type', 'plain_text'); - $this->assertSession()->waitForElementVisible('css', '#string'); - $page->selectFieldOption('group_field_options_wrapper', 'string'); - } - else { - $page->selectFieldOption('new_storage_type', 'string'); + $page->selectFieldOption('new_storage_type', 'plain_text'); + $this->assertSession()->waitForElementVisible('css', '#string'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); } + $page->selectFieldOption('group_field_options_wrapper', 'string'); $page->fillField('label', 'Text'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'text'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $page->pressButton('Save settings'); - } - else { - $page->pressButton('Save and continue'); - $page->pressButton('Save field settings'); - $page->pressButton('Save settings'); - } + $page->pressButton('Continue'); + $page->pressButton('Save settings'); // Add a paragraphed test. $this->drupalGet('node/add/paragraphed_test'); // Add 3 paragraphs. @@ -177,7 +168,6 @@ public function testAddParagraphAboveButton() { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $second_original_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -185,7 +175,6 @@ public function testAddParagraphAboveButton() { // Add a new paragraph in order to test that the new paragraph is added at the bottom. $page->pressButton('Add Paragraph'); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -267,7 +256,6 @@ public function testAddParagraphAboveButton() { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $second_original_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('rich_paragraph'); $assert_session->assertWaitOnAjaxRequest(); @@ -276,7 +264,6 @@ public function testAddParagraphAboveButton() { // Add a text nested paragraph. $add_paragraph_rich_row->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -299,7 +286,6 @@ public function testAddParagraphAboveButton() { $field_storage->save(); // Add the Paragraph back. $add_paragraph_rich_row->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -322,7 +308,6 @@ public function testAddParagraphAboveButton() { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_nested_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -346,7 +331,6 @@ public function testAddParagraphAboveButton() { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -366,7 +350,6 @@ public function testAddParagraphAboveButton() { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); diff --git a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php index 8f4bc8e319dff755a57971eb1d1309c23258b345..9e89e32282dddd538e2259c46bb7fe4652a2a45b 100644 --- a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php +++ b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php @@ -51,40 +51,24 @@ public function testEntityReferenceTargetTypeWarning() { $this->drupalGet('admin/structure/types/manage/example/fields/add-field'); $page = $this->getSession()->getPage(); - if ($this->coreVersion('10.2')) { - $page->find('css', "[name='new_storage_type'][value='reference']")->getParent()->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); - $page->fillField('label', 'unsupported field'); - $page->find('css', "[name='group_field_options_wrapper'][value='entity_reference']")->getParent()->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); + $page->find('css', "[name='new_storage_type'][value='reference']")->getParent()->click(); + if ($this->coreVersion('10.3')) { $page->pressButton('Continue'); - - $this->assertSession()->pageTextNotContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); - $page->selectFieldOption('field_storage[subform][settings][target_type]', 'paragraph'); - - $this->assertSession()->pageTextContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); } else { - $page->selectFieldOption('new_storage_type', 'entity_reference'); $this->assertSession()->assertWaitOnAjaxRequest(); - $page->fillField('label', 'unsupported field'); - $this->assertSession()->waitForElement('css', 'button.link'); - sleep(1); - - $page->pressButton('Save and continue'); - if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) { - $html_output = 'GET request to: ' . $this->getUrl() . - '<hr />Ending URL: ' . $this->getSession()->getCurrentUrl(); - $html_output .= '<hr />' . $this->getSession()->getPage()->getContent(); - $html_output .= $this->getHtmlOutputHeaders(); - $this->htmlOutput($html_output); - } + } + $page->fillField('label', 'unsupported field'); + $page->find('css', "[name='group_field_options_wrapper'][value='entity_reference']")->getParent()->click(); + if (!$this->coreVersion('10.3')) { + $this->assertSession()->assertWaitOnAjaxRequest(); + } + $page->pressButton('Continue'); - $this->assertSession()->pageTextNotContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); - $page->selectFieldOption('settings[target_type]', 'paragraph'); + $this->assertSession()->pageTextNotContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); + $page->selectFieldOption('field_storage[subform][settings][target_type]', 'paragraph'); - $this->assertSession()->pageTextContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); - } + $this->assertSession()->pageTextContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); } diff --git a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php index 04403bccf84f0c160cbd5e603c464c25e3279200..5250a8e85ca00c0b95567b4f4a798621f70a851f 100644 --- a/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php +++ b/web/modules/paragraphs/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php @@ -196,25 +196,18 @@ public function testTabsVisibility() { $this->drupalGet('admin/structure/types/manage/testcontent/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'testparagraphfield'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); $page->fillField('field_name', 'testparagraphfield'); - if ($this->coreVersion('10.2')) { - $page->pressButton('Continue'); - $edit = [ - 'field_storage[subform][settings][target_type]' => 'paragraph', - ]; - $this->submitForm($edit, 'Save settings'); - } - else { - $page->pressButton('Save and continue'); - $edit = [ - 'settings[target_type]' => 'paragraph', - ]; - $this->submitForm($edit, 'Save field settings'); - $this->submitForm([], 'Save settings'); - } + $page->pressButton('Continue'); + $edit = [ + 'field_storage[subform][settings][target_type]' => 'paragraph', + ]; + $this->submitForm($edit, 'Save settings'); $this->drupalGet('node/add/testcontent'); $style_selector = $page->find('css', '.paragraphs-tabs'); diff --git a/web/modules/paragraphs/tests/src/Kernel/Feeds/Target/ParagraphsTest.php b/web/modules/paragraphs/tests/src/Kernel/Feeds/Target/ParagraphsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0a075d4a34ac65fd3fc8df31827f363dbf7eee27 --- /dev/null +++ b/web/modules/paragraphs/tests/src/Kernel/Feeds/Target/ParagraphsTest.php @@ -0,0 +1,102 @@ +<?php + +namespace Drupal\Tests\paragraphs\Kernel\Feeds\Target; + +use Drupal\node\Entity\Node; +use Drupal\paragraphs\Entity\Paragraph; +use Drupal\Tests\feeds\Kernel\FeedsKernelTestBase; +use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait; + +/** + * @coversDefaultClass \Drupal\paragraphs\Feeds\Target\Paragraphs + * @group paragraphs + */ +class ParagraphsTest extends FeedsKernelTestBase { + + use ParagraphsTestBaseTrait; + + /** + * Modules to enable. + * + * @var string[] + */ + protected static $modules = [ + 'field', + 'feeds', + 'node', + 'entity_reference_revisions', + 'paragraphs', + 'file', + 'text', + ]; + + /** + * The feed type. + * + * @var \Drupal\feeds\FeedTypeInterface + */ + protected $feedType; + + /** + * {@inheritdoc} + */ + public function setUp(): void { + parent::setUp(); + + $this->installEntitySchema('paragraph'); + + // Create feed type. + $this->feedType = $this->createFeedTypeForCsv([ + 'guid' => 'guid', + 'title' => 'title', + 'alpha' => 'alpha', + ]); + + // Add a Paragraph field to the article content type. + $this->addParagraphsField('article', 'field_paragraphs', 'node'); + + $this->addParagraphsType('test_paragraph'); + $this->addFieldtoParagraphType('test_paragraph', 'field_text', 'text'); + + drupal_flush_all_caches(); + } + + /** + * Tests importing from a timestamp. + */ + public function testImportParagraph() { + $this->feedType->addMapping([ + 'target' => 'field_paragraphs', + 'map' => ['value' => 'alpha'], + 'settings' => [ + 'paragraphs_type' => 'test_paragraph', + 'paragraph_field' => 'field_text', + 'language' => '', + 'format' => 'plain_text', + ], + ]); + $this->feedType->save(); + + // Import. + $feed = $this->createFeed($this->feedType->id(), [ + 'source' => $this->resourcesPath() . '/csv/content.csv', + ]); + $feed->import(); + + // Assert two created nodes with paragraphs. + $this->assertNodeCount(2); + + $expected = [ + 1 => 'Lorem', + 2 => 'Ut wisi', + ]; + foreach ($expected as $nid => $value) { + // Load the node and then the paragraph. + $node = Node::load($nid); + $paragraph = Paragraph::load($node->field_paragraphs->target_id); + + $this->assertEquals($value, $paragraph->field_text->value); + } + } + +} diff --git a/web/modules/paragraphs/tests/src/Kernel/ParagraphsAccessTest.php b/web/modules/paragraphs/tests/src/Kernel/ParagraphsAccessTest.php index eec1a1aec8c1461e0bef96903401225489a7d33f..6e9633b3ae2e95c7a346e0c10983120c34837cbc 100644 --- a/web/modules/paragraphs/tests/src/Kernel/ParagraphsAccessTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/ParagraphsAccessTest.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\paragraphs\Kernel; use Drupal\Core\Access\AccessResult; +use Drupal\Core\Access\AccessResultInterface; +use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\Context\CacheContextsManager; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\KernelTests\KernelTestBase; @@ -26,33 +28,35 @@ class ParagraphsAccessTest extends KernelTestBase { * * @dataProvider createAccessTestCases */ - public function testCreateAccess($request_format, $expected_result) { + public function testCreateAccess($request_format, AccessResult $expected_result) { + + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); + $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); + $cache_contexts_manager->reveal(); + $this->container->set('cache_contexts_manager', $cache_contexts_manager); + + $expected_result->addCacheContexts(['request_format']); + $request = new Request(); $request->setRequestFormat($request_format); $this->container->get('request_stack')->push($request); $result = $this->container->get('entity_type.manager')->getAccessControlHandler('paragraph')->createAccess(NULL, NULL, [], TRUE); $this->assertEquals($expected_result, $result); + $this->container->get('request_stack')->pop(); } /** * Test cases for ::testCreateAccess. */ - public function createAccessTestCases() { - $container = new ContainerBuilder(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); - $container->set('cache_contexts_manager', $cache_contexts_manager); - \Drupal::setContainer($container); - + public static function createAccessTestCases() { return [ 'Allowed HTML request format' => [ 'html', - AccessResult::allowed()->addCacheContexts(['request_format']), + AccessResult::allowed(), ], 'Forbidden other formats' => [ 'json', - AccessResult::neutral()->addCacheContexts(['request_format']), + AccessResult::neutral(), ], ]; } diff --git a/web/modules/paragraphs/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php b/web/modules/paragraphs/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php index 6b926c939c8aed7fcc5b811de384ff180c288de4..f3063ee8f713003132f7c76edab6650e15a326ad 100644 --- a/web/modules/paragraphs/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php @@ -9,7 +9,7 @@ use Drupal\paragraphs\Entity\Paragraph; use Drupal\paragraphs\Entity\ParagraphsType; use Drupal\KernelTests\KernelTestBase; -use Drupal\Tests\field\Traits\EntityReferenceTestTrait; +use Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait; /** @@ -19,7 +19,7 @@ */ class ParagraphsCollapsedSummaryTest extends KernelTestBase { - use EntityReferenceTestTrait; + use EntityReferenceFieldCreationTrait; use UserCreationTrait; /** @@ -101,7 +101,7 @@ public function testCollapsedSummaryOptions() { // Load the paragraph and assert its stored feature settings. $paragraph = Paragraph::load($paragraph->id()); $this->assertEquals($paragraph->getAllBehaviorSettings(), $feature_settings); - $this->assertEquals($paragraph->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Text color</span>red</span></div></div>'); + $this->assertEquals((string) $paragraph->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Text color</span>red</span></div></div>'); // Check the summary and the additional options. $paragraph_1 = Paragraph::create([ @@ -111,12 +111,12 @@ public function testCollapsedSummaryOptions() { $paragraph_1->save(); // We do not include behavior summaries of nested children in the parent // summary. - $this->assertEquals($paragraph_1->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div></div>'); + $this->assertEquals((string) $paragraph_1->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div></div>'); $info = $paragraph_1->getIcons(); $this->assertEquals($info['count']['#prefix'], '<span class="paragraphs-badge" title="1 child">'); $this->assertEquals($info['count']['#suffix'], '</span>'); - $this->assertEquals($paragraph_1->getSummary(['depth_limit' => 0]), ''); + $this->assertEquals((string) $paragraph_1->getSummary(['depth_limit' => 0]), ''); } /** @@ -150,8 +150,8 @@ public function testNestedParagraphSummary() { 'nested_paragraph_field' => [$paragraph_text_2, $paragraph_nested_1], ]); $paragraph_nested_2->save(); - $this->assertEquals($paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span></div></div>'); - $this->assertEquals($paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE, 'depth_limit' => 2]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span>, <span class="summary-content">Text paragraph on nested level</span></div></div>'); + $this->assertEquals((string) $paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span></div></div>'); + $this->assertEquals((string) $paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE, 'depth_limit' => 2]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span>, <span class="summary-content">Text paragraph on nested level</span></div></div>'); $info = $paragraph_nested_2->getIcons(); $this->assertEquals($info['count']['#prefix'], '<span class="paragraphs-badge" title="2 children">'); $this->assertEquals($info['count']['#suffix'], '</span>'); @@ -181,7 +181,7 @@ public function testMultipleEntityReferences() { $paragraph_with_multiple_entity_references->get('field_user_references')->appendItem($user1->id()); $paragraph_with_multiple_entity_references->get('field_user_references')->appendItem($user2->id()); $paragraph_with_multiple_entity_references->save(); - $this->assertEquals('<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">bob</span>, <span class="summary-content">pete</span></div></div>', $paragraph_with_multiple_entity_references->getSummary()); + $this->assertEquals('<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">bob</span>, <span class="summary-content">pete</span></div></div>', (string) $paragraph_with_multiple_entity_references->getSummary()); } /** diff --git a/web/modules/paragraphs/tests/src/Kernel/ParagraphsLangcodeChangeTest.php b/web/modules/paragraphs/tests/src/Kernel/ParagraphsLangcodeChangeTest.php index 2cdcf9608d2a99d349c8e155052b4dc76f0e4cbe..b4f06e1c9f25b669c89535cf308e0d885e6e6235 100644 --- a/web/modules/paragraphs/tests/src/Kernel/ParagraphsLangcodeChangeTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/ParagraphsLangcodeChangeTest.php @@ -203,7 +203,7 @@ protected function setUp(): void { $this->formDisplay = EntityFormDisplay::load('node.' . $this->nodeType . '.default'); - $this->createUser(['uid' => 1, 'name' => 'user1'])->save(); + $this->createUser([], 'user1', TRUE)->save(); $this->paragraph = $this->entityTypeManager->getStorage('paragraph')->create([ 'type' => $this->paragraphType, diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemRevisionSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemRevisionSourceTest.php index 5136f27505bf96311dd01afe3704b4e774785a2e..0a75c1909089fd04d862d9f4c66b0b770ed80586 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemRevisionSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemRevisionSourceTest.php @@ -22,9 +22,9 @@ class FieldCollectionItemRevisionSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'item_id' => '2', 'revision_id' => '2', diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemSourceTest.php index 3a545420e5cae0cc473070d41beb40043a988d92..0075401e90554272b107902d04bf02833917e1c0 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionItemSourceTest.php @@ -22,9 +22,9 @@ class FieldCollectionItemSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'item_id' => '1', 'revision_id' => '1', diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionTypeSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionTypeSourceTest.php index dec70ed8d0d5c3720851d040049148edfd31d929..1fe9c7c326276f6e15e81512af17dfbbee526097 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionTypeSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/FieldCollectionTypeSourceTest.php @@ -22,9 +22,9 @@ class FieldCollectionTypeSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'id' => '1', 'field_name' => 'field_field_collection_field', diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphContentMigrationTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphContentMigrationTest.php index 24f48e5e8d318e1d7b780f571693a792984e8731..7bb2ca68c7ffae668621d26cb2adb7ca9bddc9d7 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphContentMigrationTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphContentMigrationTest.php @@ -93,12 +93,12 @@ public function testParagraphContentMigration($migration_to_run) { * @return string[][] * The node migration to run. */ - public function providerParagraphContentMigration() { + public static function providerParagraphContentMigration() { return [ - ['node_migration' => NULL], - ['node_migration' => 'd7_node_revision:paragraphs_test'], - ['node_migration' => 'd7_node_translation:paragraphs_test'], - ['node_migration' => 'd7_node_complete:paragraphs_test'], + ['migration_to_run' => NULL], + ['migration_to_run' => 'd7_node_revision:paragraphs_test'], + ['migration_to_run' => 'd7_node_translation:paragraphs_test'], + ['migration_to_run' => 'd7_node_complete:paragraphs_test'], ]; } diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemRevisionSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemRevisionSourceTest.php index fca6b996430d1ea7a43edeba6232bd3c8d5ced45..0227bb717e05a33162abe30876e4738259938bd4 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemRevisionSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemRevisionSourceTest.php @@ -22,9 +22,9 @@ class ParagraphsItemRevisionSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'item_id' => '2', 'revision_id' => '2', diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemSourceTest.php index f55a234a4c929782ade9c3d13a5ae2445cc1f6a9..485025e9c40d82e6accdcc40f9d651e78031a74a 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsItemSourceTest.php @@ -22,9 +22,9 @@ class ParagraphsItemSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'item_id' => '1', 'revision_id' => '1', diff --git a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsTypeSourceTest.php b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsTypeSourceTest.php index 565b5837f6dfeb25f815ca02e998973e43ec4409..fc930ff5e1c8b08504b562f74cad7be013e4c7ef 100644 --- a/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsTypeSourceTest.php +++ b/web/modules/paragraphs/tests/src/Kernel/migrate/ParagraphsTypeSourceTest.php @@ -22,9 +22,9 @@ class ParagraphsTypeSourceTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public function providerSource() { - $data = $this->getSourceData(); - $data[0]['expected_results'] = [ + public static function providerSource() { + $data = static::getSourceData(); + $data[0]['expected_data'] = [ [ 'bundle' => 'paragraphs_field', 'name' => 'Paragraphs Field', diff --git a/web/modules/paragraphs/tests/src/Traits/FieldCollectionSourceData.php b/web/modules/paragraphs/tests/src/Traits/FieldCollectionSourceData.php index 561330ee5df0691fa8125cc403da21a1281dba0f..03a5eb7daa193d91a3e006bc82fb80ff4da494d9 100644 --- a/web/modules/paragraphs/tests/src/Traits/FieldCollectionSourceData.php +++ b/web/modules/paragraphs/tests/src/Traits/FieldCollectionSourceData.php @@ -13,7 +13,7 @@ trait FieldCollectionSourceData { * @return array * The source data */ - protected function getSourceData() { + protected static function getSourceData() { $data = []; $data[]['source_data'] = [ diff --git a/web/modules/paragraphs/tests/src/Traits/ParagraphsSourceData.php b/web/modules/paragraphs/tests/src/Traits/ParagraphsSourceData.php index aba892a72ef8256057971203d5995161a029d8a6..846b5f7a7c65f307249e05a5946980d50bd173d8 100644 --- a/web/modules/paragraphs/tests/src/Traits/ParagraphsSourceData.php +++ b/web/modules/paragraphs/tests/src/Traits/ParagraphsSourceData.php @@ -13,7 +13,7 @@ trait ParagraphsSourceData { * @return array * The source data */ - protected function getSourceData() { + protected static function getSourceData() { $data = []; $data[0]['source_data'] = [ diff --git a/web/modules/paragraphs/tests/src/Unit/migrate/FieldCollectionsFieldInstanceSettingsTest.php b/web/modules/paragraphs/tests/src/Unit/migrate/FieldCollectionsFieldInstanceSettingsTest.php index 00fafb6609b108fb130646cbf0fdd8a4ad103589..84d451708fcfd1c37cb9b980950a905c6f5bc01f 100644 --- a/web/modules/paragraphs/tests/src/Unit/migrate/FieldCollectionsFieldInstanceSettingsTest.php +++ b/web/modules/paragraphs/tests/src/Unit/migrate/FieldCollectionsFieldInstanceSettingsTest.php @@ -67,11 +67,11 @@ public function testFieldCollectionBadBundle() { * @return array * The source data and expected data. */ - public function getData() { + public static function getData() { $data = [ 'With no data' => [ - 'source_data' => [], - 'expected_results' => [ + 'source' => [], + 'expected' => [ 'handler_settings' => [ 'negate' => 0, 'target_bundles' => [ diff --git a/web/modules/paragraphs/tests/src/Unit/migrate/MigrationPluginsAltererTest.php b/web/modules/paragraphs/tests/src/Unit/migrate/MigrationPluginsAltererTest.php index 4ac93577a65896415a4eb45a86816eb0728d3e76..405073bd32e33944cd865e74119481ba646a1950 100644 --- a/web/modules/paragraphs/tests/src/Unit/migrate/MigrationPluginsAltererTest.php +++ b/web/modules/paragraphs/tests/src/Unit/migrate/MigrationPluginsAltererTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\paragraphs\Unit\migrate; +use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\paragraphs\MigrationPluginsAlterer; use Drupal\Tests\UnitTestCase; @@ -30,12 +31,11 @@ protected function setUp(): void { parent::setUp(); $logger_channel = $this->createMock('Drupal\Core\Logger\LoggerChannelInterface'); - $logger_factory = $this->getMockBuilder('Drupal\Core\Logger\LoggerChannelFactory') - ->getMock(); + $logger_factory = $this->createMock('Drupal\Core\Logger\LoggerChannelFactoryInterface'); $logger_factory->expects($this->atLeastOnce()) ->method('get') ->with('paragraphs') - ->will($this->returnValue($logger_channel)); + ->willReturn($logger_channel); $this->paragraphsMigrationPluginsAlterer = new MigrationPluginsAlterer($logger_factory); } @@ -59,7 +59,7 @@ public function testParagraphsMigrationPrepareProcess(array $input, array $expec * @return array[] * Data and expected results. */ - public function providerParagraphsMigrationPrepareProcess() { + public static function providerParagraphsMigrationPrepareProcess() { return [ // Missing property (no change). [ diff --git a/web/modules/paragraphs/tests/src/Unit/migrate/ParagraphsFieldInstanceSettingsTest.php b/web/modules/paragraphs/tests/src/Unit/migrate/ParagraphsFieldInstanceSettingsTest.php index 4bbb55c6d790a4974f8408efab53547b7d4f8cb5..879d769dab142bf8a5caa7231ef0fded1c892229 100644 --- a/web/modules/paragraphs/tests/src/Unit/migrate/ParagraphsFieldInstanceSettingsTest.php +++ b/web/modules/paragraphs/tests/src/Unit/migrate/ParagraphsFieldInstanceSettingsTest.php @@ -48,10 +48,10 @@ public function testParagraphsInstanceFieldSettings(array $source, array $expect * @return array * The source data and expected data. */ - public function getData() { + public static function getData() { $data = [ 'With one bundle allowed' => [ - 'source_data' => [ + 'source' => [ 'allowed_bundles' => [ 'paragraph_bundle_one' => 'paragraph_bundle_one', 'paragraph_bundle_two' => -1, @@ -61,7 +61,7 @@ public function getData() { 'paragraph_bundle_two' => 2, ], ], - 'expected_results' => [ + 'expected' => [ 'handler_settings' => [ 'negate' => 0, 'target_bundles' => [ @@ -97,7 +97,7 @@ public function getData() { ], ], 'With all bundles allowed' => [ - 'source_data' => [ + 'source' => [ 'allowed_bundles' => [ 'paragraph_bundle_one' => -1, 'paragraph_bundle_two' => -1, @@ -107,7 +107,7 @@ public function getData() { 'paragraph_bundle_two' => 2, ], ], - 'expected_results' => [ + 'expected' => [ 'handler_settings' => [ 'negate' => 0, 'target_bundles' => NULL, diff --git a/web/modules/paragraphs/tests/src/Unit/migrate/ProcessTestCase.php b/web/modules/paragraphs/tests/src/Unit/migrate/ProcessTestCase.php index 0dfca72955764c5802d5066f85c93915222c2f56..07ad2176411218b4bb696fdde3318bc0d1626ffa 100644 --- a/web/modules/paragraphs/tests/src/Unit/migrate/ProcessTestCase.php +++ b/web/modules/paragraphs/tests/src/Unit/migrate/ProcessTestCase.php @@ -23,9 +23,7 @@ abstract class ProcessTestCase extends MigrateProcessTestCase { protected function setUp(): void { parent::setUp(); - $this->entityTypeBundleInfo = $this->getMockBuilder(EntityTypeBundleInfo::class) - ->disableOriginalConstructor() - ->getMock(); + $this->entityTypeBundleInfo = $this->createMock(EntityTypeBundleInfo::class); $bundles = [ 'paragraph_bundle_one' => [], 'paragraph_bundle_two' => [],