class ParagraphsFieldGroupTest

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsFieldGroupTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsFieldGroupTest
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsFieldGroupTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsFieldGroupTest

Tests the field group on node.

@group paragraphs @requires module field_group

Hierarchy

Expanded class hierarchy of ParagraphsFieldGroupTest

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsFieldGroupTest.php, line 11

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable
View source
class ParagraphsFieldGroupTest extends ParagraphsTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'field_group',
  ];

  /**
   * Tests the field group inside paragraph.
   */
  public function testFieldGroup() {
    $this
      ->loginAsAdmin();
    $paragraph_type = 'paragraph_type_test';
    $content_type = 'paragraphed_test';

    // Add a Paragraphed test content type.
    $this
      ->addParagraphedContentType($content_type);
    $this
      ->addParagraphsType($paragraph_type);
    $this
      ->addParagraphsType('text');
    static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);

    // Create the field group element on paragraph type.
    $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');

    // Put the text field into the field 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');

    // Create a node with a paragraph.
    $this
      ->drupalGet('node/add/' . $content_type);
    $this
      ->drupalGet('node/add/' . $content_type);
    $this
      ->submitForm([], 'field_paragraphs_paragraph_type_test_add_more');

    // Test if the new field group is displayed.
    $this
      ->assertSession()
      ->pageTextContains('field_group');
    $this
      ->assertSession()
      ->elementExists('css', 'fieldset');

    // Save the node.
    $edit = [
      'title[0][value]' => 'paragraphed_title',
      'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value',
    ];
    $this
      ->submitForm($edit, 'Save');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParagraphsFieldGroupTest::$modules protected static property Modules to enable. Overrides ParagraphsTestBase::$modules
ParagraphsFieldGroupTest::testFieldGroup public function Tests the field group inside paragraph.
ParagraphsTestBase::$admin_permissions protected property List of permissions used by loginAsAdmin().
ParagraphsTestBase::$admin_user protected property Drupal user object created by loginAsAdmin(). 1
ParagraphsTestBase::$defaultTheme protected property 2
ParagraphsTestBase::loginAsAdmin function Creates an user with admin permissions and log in.
ParagraphsTestBase::removeDefaultParagraphType protected function Removes the default paragraph type. Overrides ParagraphsTestBase::removeDefaultParagraphType
ParagraphsTestBase::setAddMode protected function Sets the Paragraphs widget add mode. Overrides ParagraphsTestBase::setAddMode
ParagraphsTestBase::setAllowedParagraphsTypes protected function Sets the allowed Paragraphs types that can be added.
ParagraphsTestBase::setDefaultParagraphType protected function Sets the default paragraph type.
ParagraphsTestBase::setParagraphsTypeWeight protected function Sets the weight of a given Paragraphs type.
ParagraphsTestBase::setParagraphsWidgetMode protected function Sets the Paragraphs widget display mode.
ParagraphsTestBase::setUp protected function 19
ParagraphsTestBaseTrait::$workflow protected property The workflow entity.
ParagraphsTestBaseTrait::addFieldtoParagraphType protected function Adds a field to a given paragraph type.
ParagraphsTestBaseTrait::addParagraphedContentType protected function Adds a content type with a Paragraphs field.
ParagraphsTestBaseTrait::addParagraphsField protected function Adds a Paragraphs field to a given entity type.
ParagraphsTestBaseTrait::addParagraphsType protected function Adds a Paragraphs type.
ParagraphsTestBaseTrait::addParagraphsTypeIcon protected function Adds an icon to a paragraphs type.
ParagraphsTestBaseTrait::createEditorialWorkflow protected function Creates a workflow entity.
ParagraphsTestBaseTrait::setParagraphsWidgetSettings protected function Sets some of the settings of a paragraphs field widget.