class ParagraphsCollectionStyleTest

Same name in this branch
  1. 8.x-1.x paragraphs_collection/tests/src/FunctionalJavascript/ParagraphsCollectionStyleTest.php \Drupal\Tests\paragraphs_collection\FunctionalJavascript\ParagraphsCollectionStyleTest
  2. 8.x-1.x paragraphs_collection/tests/src/Functional/ParagraphsCollectionStyleTest.php \Drupal\Tests\paragraphs_collection\Functional\ParagraphsCollectionStyleTest

Test paragraphs collection style behavior.

@group paragraphs_collection

Hierarchy

Expanded class hierarchy of ParagraphsCollectionStyleTest

File

paragraphs_collection/tests/src/FunctionalJavascript/ParagraphsCollectionStyleTest.php, line 14

Namespace

Drupal\Tests\paragraphs_collection\FunctionalJavascript
View source
class ParagraphsCollectionStyleTest extends WebDriverTestBase {
  use LoginAdminTrait;
  use ParagraphsTestBaseTrait;

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'node',
    'paragraphs_collection_test',
    'paragraphs_collection',
    'field',
    'field_ui',
    'block',
    'link',
    'text',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * Test paragraphs style behavior plugin.
   */
  public function testStylePlugin() {
    $this
      ->loginAsAdmin([
      'access content overview',
      'edit behavior plugin settings',
    ]);
    $page = $this
      ->getSession()
      ->getPage();
    $this
      ->drupalGet('admin/structure/paragraphs_type/add');
    $page
      ->fillField('label', 'TestPlugin');
    $this
      ->assertSession()
      ->waitForElementVisible('css', '#edit-name-machine-name-suffix .link');
    $page
      ->pressButton('Edit');
    $page
      ->fillField('id', 'testplugin');
    $this
      ->click('#edit-behavior-plugins-style-enabled');
    $this
      ->click('#edit-behavior-plugins-style-settings-groups-regular-test-group');
    $this
      ->assertSession()
      ->assertWaitOnAjaxRequest();
    $page
      ->fillField('label', 'TestPlugin');
    $this
      ->assertSession()
      ->assertWaitOnAjaxRequest();
    $edit = [
      'behavior_plugins[style][settings][groups_defaults][regular_test_group][default]' => '',
    ];
    $this
      ->submitForm($edit, t('Save and manage fields'));
    $this
      ->addParagraphedContentType('testcontent', 'testparagraphfield');
    $this
      ->drupalGet('node/add/testcontent');
    $this
      ->click('.dropbutton-toggle');
    $page
      ->pressButton('Add TestPlugin');
    $this
      ->assertSession()
      ->assertWaitOnAjaxRequest();
    $this
      ->clickLink('Behavior');
    $style_selector = $this
      ->getSession()
      ->getPage()
      ->find('css', '.form-item-testparagraphfield-0-behavior-plugins-style-style-wrapper-styles-regular-test-group');
    $this
      ->assertTrue($style_selector
      ->isVisible());
    $this
      ->clickLink('Content');
    $this
      ->assertFalse($style_selector
      ->isVisible());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LoginAdminTrait::$admin_user protected property Drupal user object created by loginAsAdmin().
LoginAdminTrait::loginAsAdmin public function Creates an user with admin permissions and log in.
ParagraphsCollectionStyleTest::$defaultTheme protected property
ParagraphsCollectionStyleTest::$modules protected static property Modules to enable.
ParagraphsCollectionStyleTest::testStylePlugin public function Test paragraphs style behavior plugin.
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::coreVersion protected function Checks the core version.
ParagraphsTestBaseTrait::createEditorialWorkflow protected function Creates a workflow entity.
ParagraphsTestBaseTrait::setParagraphsWidgetSettings protected function Sets some of the settings of a paragraphs field widget.