3 namespace Drupal\paragraphs\Tests\Experimental;
6 * Tests the field group on node.
9 * @requires module field_group
11 class ParagraphsExperimentalFieldGroupTest extends ParagraphsExperimentalTestBase {
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);
34 $this->addParagraphsType($paragraph_type);
35 $this->addParagraphsType('text');
36 static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
38 // Create the field group element on paragraph type.
40 'group_formatter' => 'fieldset',
41 'label' => 'paragraph_field_group_title',
42 'group_name' => 'field'
44 $this->drupalPostForm('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display/add-group', $edit, t('Save and continue'));
46 'format_settings[label]' => 'field_group'
48 $this->drupalPostForm(NULL, $edit, t('Create group'));
50 // Put the text field into the field group.
52 'fields[field_text][parent]' => 'group_field'
54 $this->drupalPostForm('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display', $edit, t('Save'));
56 // Create a node with a paragraph.
57 $this->drupalGet('node/add/' . $content_type);
58 $this->drupalPostAjaxForm('node/add/' . $content_type, [], 'field_paragraphs_paragraph_type_test_add_more');
60 // Test if the new field group is displayed.
61 $this->assertText('field_group');
62 $this->assertFieldByXPath("//fieldset", NULL, t('Fieldset present'));
66 'title[0][value]' => 'paragraphed_title',
67 'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value',
69 $this->drupalPostForm(NULL, $edit, t('Save'));