diff --git a/src/Tests/Classic/ParagraphsAddModesTest.php b/src/Tests/Classic/ParagraphsAddModesTest.php index 20372d5..f110fbf 100644 --- a/src/Tests/Classic/ParagraphsAddModesTest.php +++ b/src/Tests/Classic/ParagraphsAddModesTest.php @@ -19,7 +19,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { */ public function testNoDefaultValue() { $this->loginAsAdmin(); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'entity_reference_paragraphs'); // Edit the field. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields'); @@ -37,7 +37,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { */ public function testEmptyAllowedTypes() { $this->loginAsAdmin(); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); // Edit the field and save when there are no paragraphs types available. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields'); @@ -55,7 +55,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { $this->addParagraphsType('btext'); $this->addParagraphsType('dtext'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); // Enter to the field config since the weight is set through the form. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs'); $this->drupalPostForm(NULL, [], 'Save settings'); @@ -89,7 +89,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { $this->addParagraphsType('btext'); $this->addParagraphsType('dtext'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); // Enter to the field config since the weight is set through the form. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs'); $this->drupalPostForm(NULL, [], 'Save settings'); @@ -153,7 +153,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { * Tests if setting for default paragraph type is working properly. */ public function testSettingDefaultParagraphType() { - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin([ 'administer content types', 'administer node form display', @@ -199,7 +199,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { * Tests the default paragraph type behavior for a field with a single type. */ public function testDefaultParagraphTypeWithSingleType() { - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin([ 'administer content types', 'administer node form display', diff --git a/src/Tests/Classic/ParagraphsAdministrationTest.php b/src/Tests/Classic/ParagraphsAdministrationTest.php index 03e6116..b111028 100644 --- a/src/Tests/Classic/ParagraphsAdministrationTest.php +++ b/src/Tests/Classic/ParagraphsAdministrationTest.php @@ -37,7 +37,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { * Tests the revision of paragraphs. */ public function testParagraphsRevisions() { - $this->addParagraphedContentType('article', 'paragraphs'); + $this->addParagraphedContentType('article', 'paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin([ 'create paragraphs content', 'administer node display', @@ -128,7 +128,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { */ public function testParagraphsCreation() { // Create an article with paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin([ 'administer site configuration', 'create article content', diff --git a/src/Tests/Classic/ParagraphsConfigTest.php b/src/Tests/Classic/ParagraphsConfigTest.php index 4fff146..01ae4d5 100644 --- a/src/Tests/Classic/ParagraphsConfigTest.php +++ b/src/Tests/Classic/ParagraphsConfigTest.php @@ -33,7 +33,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { ]); // Add a paragraphed content type. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'entity_reference_paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); @@ -79,7 +79,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { $this->drupalGet('admin/config/regional/content-language'); $this->assertText('(* unsupported) Paragraphs fields do not support translation.'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'entity_reference_paragraphs'); // Check error message is not displayed. $this->drupalGet('admin/config/regional/content-language'); @@ -139,7 +139,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { $this->loginAsAdmin(); // Add a Paragraph content type and 2 Paragraphs types. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); @@ -197,7 +197,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { public function testIncludedParagraphTypes() { $this->loginAsAdmin(); // Add a Paragraph content type and 2 Paragraphs types. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); @@ -220,7 +220,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { public function testExcludedParagraphTypes() { $this->loginAsAdmin(); // Add a Paragraph content type and 2 Paragraphs types. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); diff --git a/src/Tests/Classic/ParagraphsContactTest.php b/src/Tests/Classic/ParagraphsContactTest.php index 5cf8287..6ed36c0 100644 --- a/src/Tests/Classic/ParagraphsContactTest.php +++ b/src/Tests/Classic/ParagraphsContactTest.php @@ -36,7 +36,7 @@ class ParagraphsContactTest extends ParagraphsTestBase { $contact_form = ContactForm::create(['id' => 'test_contact_form']); $contact_form->save(); // Add a paragraphs field to the contact form. - $this->addParagraphsField($contact_form->id(), 'paragraphs', 'contact_message'); + $this->addParagraphsField($contact_form->id(), 'paragraphs', 'contact_message', 'entity_reference_paragraphs'); // Add a paragraph to the contact form. $this->drupalGet('contact/test_contact_form'); diff --git a/src/Tests/Classic/ParagraphsEditModesTest.php b/src/Tests/Classic/ParagraphsEditModesTest.php index afeda36..31e1c26 100644 --- a/src/Tests/Classic/ParagraphsEditModesTest.php +++ b/src/Tests/Classic/ParagraphsEditModesTest.php @@ -26,7 +26,7 @@ class ParagraphsEditModesTest extends ParagraphsTestBase { * Tests the collapsed summary of paragraphs. */ public function testCollapsedSummary() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. diff --git a/src/Tests/Classic/ParagraphsFieldGroupTest.php b/src/Tests/Classic/ParagraphsFieldGroupTest.php index 70f1ff8..00ecf32 100644 --- a/src/Tests/Classic/ParagraphsFieldGroupTest.php +++ b/src/Tests/Classic/ParagraphsFieldGroupTest.php @@ -29,7 +29,7 @@ class ParagraphsFieldGroupTest extends ParagraphsTestBase { $content_type = 'paragraphed_test'; // Add a Paragraphed test content type. - $this->addParagraphedContentType($content_type, 'field_paragraphs'); + $this->addParagraphedContentType($content_type, 'field_paragraphs', 'entity_reference_paragraphs'); $this->addParagraphsType($paragraph_type); $this->addParagraphsType('text'); static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []); diff --git a/src/Tests/Classic/ParagraphsInlineEntityFormTest.php b/src/Tests/Classic/ParagraphsInlineEntityFormTest.php index d7d677c..e7b7a3f 100644 --- a/src/Tests/Classic/ParagraphsInlineEntityFormTest.php +++ b/src/Tests/Classic/ParagraphsInlineEntityFormTest.php @@ -23,7 +23,7 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { */ public function testParagraphsIEFPreview() { // Create article content type with a paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin(['create article content', 'edit any article content']); // Create the paragraphs type simple. @@ -75,7 +75,7 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { public function testParagraphsIEFChangeOrder() { // Create article content type with a paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin(['create article content', 'edit any article content']); // Create the paragraphs type simple. diff --git a/src/Tests/Classic/ParagraphsPreviewTest.php b/src/Tests/Classic/ParagraphsPreviewTest.php index bc89072..3ab6798 100644 --- a/src/Tests/Classic/ParagraphsPreviewTest.php +++ b/src/Tests/Classic/ParagraphsPreviewTest.php @@ -27,7 +27,7 @@ class ParagraphsPreviewTest extends ParagraphsTestBase { */ public function testParagraphsPreview() { // Create paragraph type Headline + Block. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin([ 'administer node display', 'create article content', diff --git a/src/Tests/Classic/ParagraphsSummaryFormatterTest.php b/src/Tests/Classic/ParagraphsSummaryFormatterTest.php index 62a8651..aeb134e 100644 --- a/src/Tests/Classic/ParagraphsSummaryFormatterTest.php +++ b/src/Tests/Classic/ParagraphsSummaryFormatterTest.php @@ -26,7 +26,7 @@ class ParagraphsSummaryFormatterTest extends ParagraphsTestBase { * Tests the paragraphs summary formatter. */ public function testParagraphsSummaryFormatter() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content', 'administer node display']); // Add a Paragraph type. diff --git a/src/Tests/Classic/ParagraphsTestBase.php b/src/Tests/Classic/ParagraphsTestBase.php index 656e131..ea6abfb 100644 --- a/src/Tests/Classic/ParagraphsTestBase.php +++ b/src/Tests/Classic/ParagraphsTestBase.php @@ -10,13 +10,14 @@ use Drupal\field_ui\Tests\FieldUiTestTrait; use Drupal\node\Entity\NodeType; use Drupal\paragraphs\Entity\ParagraphsType; use Drupal\simpletest\WebTestBase; +use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait; /** * Base class for tests. */ abstract class ParagraphsTestBase extends WebTestBase { - use FieldUiTestTrait, ParagraphsCoreVersionUiTestTrait; + use FieldUiTestTrait, ParagraphsCoreVersionUiTestTrait, ParagraphsTestBaseTrait; /** * Drupal user object created by loginAsAdmin(). @@ -96,89 +97,6 @@ abstract class ParagraphsTestBase extends WebTestBase { } /** - * Adds a content type with a Paragraphs field. - * - * @param string $content_type_name - * Content type name to be used. - * @param string $paragraphs_field_name - * Paragraphs field name to be used. - */ - protected function addParagraphedContentType($content_type_name, $paragraphs_field_name) { - // Create the content type. - $node_type = NodeType::create([ - 'type' => $content_type_name, - 'name' => $content_type_name, - ]); - $node_type->save(); - - $this->addParagraphsField($content_type_name, $paragraphs_field_name, 'node'); - } - - /** - * Adds a Paragraphs field to a given $entity_type. - * - * @param string $entity_type_name - * Entity type name to be used. - * @param string $paragraphs_field_name - * Paragraphs field name to be used. - * @param string $entity_type - * Entity type where to add the field. - */ - protected function addParagraphsField($entity_type_name, $paragraphs_field_name, $entity_type) { - // Add a paragraphs field. - $field_storage = FieldStorageConfig::create([ - 'field_name' => $paragraphs_field_name, - 'entity_type' => $entity_type, - 'type' => 'entity_reference_revisions', - 'cardinality' => '-1', - 'settings' => [ - 'target_type' => 'paragraph', - ], - ]); - $field_storage->save(); - $field = FieldConfig::create([ - 'field_storage' => $field_storage, - 'bundle' => $entity_type_name, - 'settings' => [ - 'handler' => 'default:paragraph', - 'handler_settings' => ['target_bundles' => NULL], - ], - ]); - $field->save(); - - $form_display = EntityFormDisplay::create([ - 'targetEntityType' => $entity_type, - 'bundle' => $entity_type_name, - 'mode' => 'default', - 'status' => TRUE, - ]) - ->setComponent($paragraphs_field_name, ['type' => 'entity_reference_paragraphs']); - $form_display->save(); - - $view_display = EntityViewDisplay::create([ - 'targetEntityType' => $entity_type, - 'bundle' => $entity_type_name, - 'mode' => 'default', - 'status' => TRUE, - ])->setComponent($paragraphs_field_name, ['type' => 'entity_reference_revisions_entity_view']); - $view_display->save(); - } - - /** - * Adds a Paragraphs type. - * - * @param string $paragraphs_type_name - * Paragraph type name used to create. - */ - protected function addParagraphsType($paragraphs_type_name) { - $paragraphs_type = ParagraphsType::create([ - 'id' => $paragraphs_type_name, - 'label' => $paragraphs_type_name, - ]); - $paragraphs_type->save(); - } - - /** * Sets the Paragraphs widget add mode. * * @param string $content_type diff --git a/src/Tests/Classic/ParagraphsTypesTest.php b/src/Tests/Classic/ParagraphsTypesTest.php index 41f3725..e9937ad 100644 --- a/src/Tests/Classic/ParagraphsTypesTest.php +++ b/src/Tests/Classic/ParagraphsTypesTest.php @@ -27,7 +27,7 @@ class ParagraphsTypesTest extends ParagraphsTestBase { $this->loginAsAdmin(); // Add a Paragraphed test content. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'entity_reference_paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); diff --git a/src/Tests/Classic/ParagraphsWidgetButtonsTest.php b/src/Tests/Classic/ParagraphsWidgetButtonsTest.php index b60ebc1..c56ab97 100644 --- a/src/Tests/Classic/ParagraphsWidgetButtonsTest.php +++ b/src/Tests/Classic/ParagraphsWidgetButtonsTest.php @@ -17,7 +17,7 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { * Tests the widget buttons of paragraphs. */ public function testWidgetButtons() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. diff --git a/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php b/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php index 15a6bc7..26eba32 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php @@ -19,7 +19,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase */ public function testNoDefaultValue() { $this->loginAsAdmin(); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'paragraphs'); // Edit the field. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields'); $this->clickLink(t('Edit')); @@ -36,7 +36,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase */ public function testEmptyAllowedTypes() { $this->loginAsAdmin(); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); // Edit the field and save when there are no paragraphs types available. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields'); @@ -54,7 +54,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase $this->addParagraphsType('btext'); $this->addParagraphsType('dtext'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); // Enter to the field config since the weight is set through the form. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs'); $this->drupalPostForm(NULL, [], 'Save settings'); @@ -88,7 +88,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase $this->addParagraphsType('btext'); $this->addParagraphsType('dtext'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); // Enter to the field config since the weight is set through the form. $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs'); $this->drupalPostForm(NULL, [], 'Save settings'); @@ -152,7 +152,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase * Tests if setting for default paragraph type is working properly. */ public function testSettingDefaultParagraphType() { - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'administer content types', 'administer node form display', @@ -198,7 +198,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase * Tests the default paragraph type behavior for a field with a single type. */ public function testDefaultParagraphTypeWithSingleType() { - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'administer content types', 'administer node form display', diff --git a/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php b/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php index 573692b..80f43b0 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php @@ -38,7 +38,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes * Tests the revision of paragraphs. */ public function testParagraphsRevisions() { - $this->addParagraphedContentType('article', 'paragraphs'); + $this->addParagraphedContentType('article', 'paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'create paragraphs content', 'administer node display', @@ -129,7 +129,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes */ public function testParagraphsCreation() { // Create an article with paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'administer site configuration', 'create article content', diff --git a/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php b/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php index f7ba8e6..6069e29 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php @@ -24,7 +24,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase * Tests the behavior plugins for paragraphs. */ public function testBehaviorPluginsFields() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. @@ -195,7 +195,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase * Tests the behavior plugins summary for paragraphs closed mode. */ public function testCollapsedSummary() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'create paragraphed_test content', 'edit any paragraphed_test content', @@ -217,7 +217,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase // Add a nested Paragraph type. $paragraph_type = 'nested_paragraph'; $this->addParagraphsType($paragraph_type); - $this->addParagraphsField('nested_paragraph', 'paragraphs', 'paragraph'); + $this->addParagraphsField('nested_paragraph', 'paragraphs', 'paragraph', 'paragraphs'); // Enable plugins for the nested paragraph type. $edit = [ 'behavior_plugins[test_bold_text][enabled]' => TRUE, @@ -250,7 +250,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase * Tests the behavior plugins subform state submit. */ public function testBehaviorSubform() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'create paragraphed_test content', 'edit any paragraphed_test content', diff --git a/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php b/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php index 4ecfee8..48564c9 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php @@ -33,8 +33,8 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { ]); // Add a paragraphed content type. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); @@ -80,7 +80,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { $this->drupalGet('admin/config/regional/content-language'); $this->assertText('(* unsupported) Paragraphs fields do not support translation.'); - $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'paragraphs'); // Check error message is not displayed. $this->drupalGet('admin/config/regional/content-language'); $this->assertText('(* unsupported) Paragraphs fields do not support translation.'); @@ -165,7 +165,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { public function testIncludedParagraphTypes() { $this->loginAsAdmin(); // Add a Paragraph content type and 2 Paragraphs types. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); @@ -212,7 +212,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { public function testExcludedParagraphTypes() { $this->loginAsAdmin(); // Add a Paragraph content type and 2 Paragraphs types. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalContactTest.php b/src/Tests/Experimental/ParagraphsExperimentalContactTest.php index 30133c9..dffccea 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalContactTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalContactTest.php @@ -36,7 +36,7 @@ class ParagraphsExperimentalContactTest extends ParagraphsExperimentalTestBase { $contact_form = ContactForm::create(['id' => 'test_contact_form']); $contact_form->save(); // Add a paragraphs field to the contact form. - $this->addParagraphsField($contact_form->id(), 'paragraphs', 'contact_message'); + $this->addParagraphsField($contact_form->id(), 'paragraphs', 'contact_message', 'paragraphs'); // Add a paragraph to the contact form. $this->drupalGet('contact/test_contact_form'); $this->drupalPostAjaxForm(NULL, [], 'paragraphs_paragraphs_contact_add_more'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php b/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php index a27922d..23f3d32 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php @@ -22,7 +22,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT * Tests duplicate paragraph feature. */ public function testDuplicateButton() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. @@ -61,7 +61,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT * Tests duplicate paragraph feature with nested paragraphs. */ public function testDuplicateButtonWithNesting() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add nested Paragraph type. diff --git a/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php b/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php index 6c512f1..a07ea8e 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php @@ -26,7 +26,7 @@ class ParagraphsExperimentalEditModesTest extends ParagraphsExperimentalTestBase * Tests the collapsed summary of paragraphs. */ public function testCollapsedSummary() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. diff --git a/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php b/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php index 3989ef1..b19a9aa 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php @@ -29,7 +29,7 @@ class ParagraphsExperimentalFieldGroupTest extends ParagraphsExperimentalTestBas $content_type = 'paragraphed_test'; // Add a Paragraphed test content type. - $this->addParagraphedContentType($content_type, 'field_paragraphs'); + $this->addParagraphedContentType($content_type, 'field_paragraphs', 'paragraphs'); $this->addParagraphsType($paragraph_type); $this->addParagraphsType('text'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php b/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php index 842ff30..e6a9212 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php @@ -23,7 +23,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT */ public function testParagraphsIEFPreview() { // Create article content type with a paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create article content', 'edit any article content']); // Create the paragraphs type simple. @@ -74,7 +74,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT */ public function testParagraphsIEFChangeOrder() { // Create article content type with a paragraphs field. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create article content', 'edit any article content']); // Create the paragraphs type simple. diff --git a/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php b/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php index e7bcc32..b34d1ce 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php @@ -28,7 +28,7 @@ class ParagraphsExperimentalPreviewTest extends ParagraphsExperimentalTestBase { */ public function testParagraphsPreview() { // Create paragraph type Headline + Block. - $this->addParagraphedContentType('article', 'field_paragraphs'); + $this->addParagraphedContentType('article', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin([ 'administer node display', 'create article content', diff --git a/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php b/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php index 7e145ec..26d0d40 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php @@ -26,7 +26,7 @@ class ParagraphsExperimentalSummaryFormatterTest extends ParagraphsExperimentalT * Tests the paragraphs summary formatter. */ public function testParagraphsSummaryFormatter() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content', 'administer node display']); // Add a Paragraph type. diff --git a/src/Tests/Experimental/ParagraphsExperimentalTestBase.php b/src/Tests/Experimental/ParagraphsExperimentalTestBase.php index 0985aa0..752b5de 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalTestBase.php +++ b/src/Tests/Experimental/ParagraphsExperimentalTestBase.php @@ -8,63 +8,14 @@ use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field_ui\Tests\FieldUiTestTrait; use Drupal\paragraphs\Tests\Classic\ParagraphsTestBase; +use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait; /** * Base class for tests. */ abstract class ParagraphsExperimentalTestBase extends ParagraphsTestBase { - use FieldUiTestTrait; - - /** - * Adds a Paragraphs field to a given $entity_type. - * - * @param string $entity_type_name - * Entity type name to be used. - * @param string $paragraphs_field_name - * Paragraphs field name to be used. - * @param string $entity_type - * Entity type where to add the field. - */ - protected function addParagraphsField($entity_type_name, $paragraphs_field_name, $entity_type) { - // Add a paragraphs field. - $field_storage = FieldStorageConfig::create([ - 'field_name' => $paragraphs_field_name, - 'entity_type' => $entity_type, - 'type' => 'entity_reference_revisions', - 'cardinality' => '-1', - 'settings' => [ - 'target_type' => 'paragraph', - ], - ]); - $field_storage->save(); - $field = FieldConfig::create([ - 'field_storage' => $field_storage, - 'bundle' => $entity_type_name, - 'settings' => [ - 'handler' => 'default:paragraph', - 'handler_settings' => ['target_bundles' => NULL], - ], - ]); - $field->save(); - - $form_display = EntityFormDisplay::create([ - 'targetEntityType' => $entity_type, - 'bundle' => $entity_type_name, - 'mode' => 'default', - 'status' => TRUE, - ]) - ->setComponent($paragraphs_field_name, ['type' => 'paragraphs']); - $form_display->save(); - - $view_display = EntityViewDisplay::create([ - 'targetEntityType' => $entity_type, - 'bundle' => $entity_type_name, - 'mode' => 'default', - 'status' => TRUE, - ])->setComponent($paragraphs_field_name, ['type' => 'entity_reference_revisions_entity_view']); - $view_display->save(); - } + use FieldUiTestTrait, ParagraphsTestBaseTrait; /** * Sets the Paragraphs widget add mode. diff --git a/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php b/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php index 0ccd1f3..919bed8 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php @@ -15,7 +15,7 @@ class ParagraphsExperimentalTypesTest extends ParagraphsExperimentalTestBase { public function testRemoveTypesWithContent() { $this->loginAsAdmin(); // Add a Paragraphed test content. - $this->addParagraphedContentType('paragraphed_test', 'paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'paragraphs', 'paragraphs'); $this->addParagraphsType('paragraph_type_test'); $this->addParagraphsType('text'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php b/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php index ce6cbcc..627772c 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php @@ -26,7 +26,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest * Tests the widget buttons of paragraphs. */ public function testWidgetButtons() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type. @@ -107,7 +107,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest * Tests if buttons are present for each widget mode. */ public function testButtonsVisibility() { - $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs'); + $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'paragraphs'); $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content']); // Add a Paragraph type.