ParagraphsFieldGroupTest.php in Paragraphs 8
File
tests/src/Functional/WidgetLegacy/ParagraphsFieldGroupTest.php
View source
<?php
namespace Drupal\Tests\paragraphs\Functional\WidgetLegacy;
class ParagraphsFieldGroupTest extends ParagraphsTestBase {
public static $modules = [
'field_group',
];
public function testFieldGroup() {
$this
->loginAsAdmin();
$paragraph_type = 'paragraph_type_test';
$content_type = 'paragraphed_test';
$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', [], []);
$edit = [
'group_formatter' => 'fieldset',
'label' => 'paragraph_field_group_title',
'group_name' => 'field',
];
$this
->drupalGet('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display/add-group');
$this
->submitForm($edit, 'Save and continue');
$edit = [
'format_settings[label]' => 'field_group',
];
$this
->submitForm($edit, 'Create group');
$edit = [
'fields[group_field][region]' => 'content',
'fields[field_text][parent]' => 'group_field',
];
$this
->drupalGet('admin/structure/paragraphs_type/' . $paragraph_type . '/form-display');
$this
->submitForm($edit, 'Save');
$this
->drupalGet('node/add/' . $content_type);
$this
->drupalGet('node/add/' . $content_type);
$this
->submitForm([], 'field_paragraphs_paragraph_type_test_add_more');
$this
->assertSession()
->pageTextContains('field_group');
$this
->assertSession()
->elementExists('css', 'fieldset');
$edit = [
'title[0][value]' => 'paragraphed_title',
'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value',
];
$this
->submitForm($edit, 'Save');
}
}