3 namespace Drupal\paragraphs\Tests\Classic;
6 * Tests the field group on node.
9 * @requires module field_group
11 class ParagraphsFieldGroupTest extends ParagraphsTestBase {
18 public static $modules = [
23 * Tests the field group inside paragraph.
25 public function testFieldGroup() {
26 $this->loginAsAdmin();
28 $paragraph_type = 'paragraph_type_test';
29 $content_type = 'paragraphed_test';
31 // Add a Paragraphed test content type.
32 $this->addParagraphedContentType($content_type, 'field_paragraphs');
33 $this->addParagraphsType($paragraph_type);
34 $this->addParagraphsType('text');
35 static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
37 // Create the field group element on paragraph type.
39 'group_formatter' => 'fieldset',
40 'label' => 'paragraph_field_group_title',
41 'group_name' => 'field'
43 $this->drupalPostForm('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display/add-group', $edit, t('Save and continue'));
45 'format_settings[label]' => 'field_group'
47 $this->drupalPostForm(NULL, $edit, t('Create group'));
49 // Put the text field into the field group.
51 'fields[field_text][parent]' => 'group_field'
53 $this->drupalPostForm('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display', $edit, t('Save'));
55 // Create a node with a paragraph.
56 $this->drupalGet('node/add/' . $content_type);
57 $this->drupalPostAjaxForm('node/add/' . $content_type, [], 'field_paragraphs_paragraph_type_test_add_more');
59 // Test if the new field group is displayed.
60 $this->assertText('field_group');
61 $this->assertFieldByXPath("//fieldset", NULL, t('Fieldset present'));
65 'title[0][value]' => 'paragraphed_title',
66 'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value',
68 $this->drupalPostForm(NULL, $edit, t('Save and publish'));