abstract class ParagraphsTestBase

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

Base class for tests.

Hierarchy

Expanded class hierarchy of ParagraphsTestBase

17 files declare their use of ParagraphsTestBase
MultilingualBehaviorTest.php in paragraphs/modules/paragraphs_library/tests/src/Functional/MultilingualBehaviorTest.php
ParagraphsAccordionPluginTest.php in paragraphs_collection/modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsAccordionPluginTest.php
ParagraphsAnchorPluginTest.php in paragraphs_collection/modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsAnchorPluginTest.php
ParagraphsBackgroundPluginTest.php in paragraphs_collection/modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsBackgroundPluginTest.php
ParagraphsBehaviorsTest.php in paragraphs/tests/src/Functional/ParagraphsBehaviorsTest.php

... See full list

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsTestBase.php, line 12

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable
View source
abstract class ParagraphsTestBase extends LegacyParagraphsTestBase {
  use ParagraphsTestBaseTrait;

  /**
   * Sets the Paragraphs widget add mode.
   *
   * @param string $content_type
   *   Content type name where to set the widget mode.
   * @param string $paragraphs_field
   *   Paragraphs field to change the mode.
   * @param string $mode
   *   Mode to be set. ('dropdown', 'select' or 'button').
   */
  protected function setAddMode($content_type, $paragraphs_field, $mode) {
    $form_display = EntityFormDisplay::load('node.' . $content_type . '.default')
      ->setComponent($paragraphs_field, [
      'type' => 'paragraphs',
      'settings' => [
        'add_mode' => $mode,
      ],
    ]);
    $form_display
      ->save();
  }

  /**
   * Removes the default paragraph type.
   *
   * @param $content_type
   *   Content type name that contains the paragraphs field.
   */
  protected function removeDefaultParagraphType($content_type) {
    $this
      ->drupalGet('node/add/' . $content_type);
    $this
      ->submitForm([], 'Remove');
    $this
      ->assertSession()
      ->pageTextNotContains('No paragraphs added yet.');
  }

}

Members

Name Modifierssort descending Type Description Overrides
ParagraphsTestBase::loginAsAdmin function Creates an user with admin permissions and log in.
ParagraphsTestBase::setAddMode protected function Sets the Paragraphs widget add mode. Overrides ParagraphsTestBase::setAddMode
ParagraphsTestBase::removeDefaultParagraphType protected function Removes the default paragraph type. Overrides ParagraphsTestBase::removeDefaultParagraphType
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::addFieldtoParagraphType protected function Adds a field to a given paragraph type.
ParagraphsTestBaseTrait::setParagraphsWidgetSettings protected function Sets some of the settings of a paragraphs field widget.
ParagraphsTestBaseTrait::createEditorialWorkflow protected function Creates a workflow entity.
ParagraphsTestBaseTrait::coreVersion protected function Checks the core version.
ParagraphsTestBase::setUp protected function 19
ParagraphsTestBase::setAllowedParagraphsTypes protected function Sets the allowed Paragraphs types that can be added.
ParagraphsTestBase::setParagraphsTypeWeight protected function Sets the weight of a given Paragraphs type.
ParagraphsTestBase::setDefaultParagraphType protected function Sets the default paragraph type.
ParagraphsTestBase::setParagraphsWidgetMode protected function Sets the Paragraphs widget display mode.
ParagraphsTestBaseTrait::$workflow protected property The workflow entity.
ParagraphsTestBase::$admin_user protected property Drupal user object created by loginAsAdmin(). 1
ParagraphsTestBase::$admin_permissions protected property List of permissions used by loginAsAdmin().
ParagraphsTestBase::$defaultTheme protected property 2
ParagraphsTestBase::$modules protected static property Modules to enable. 48