public function ParagraphsCollectionStyleTest::testStylePlugin

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

Test paragraphs style behavior plugin.

File

paragraphs_collection/tests/src/Functional/ParagraphsCollectionStyleTest.php, line 43

Class

ParagraphsCollectionStyleTest
Test paragraphs collection style behavior.

Namespace

Drupal\Tests\paragraphs_collection\Functional

Code

public function testStylePlugin() {
  $this
    ->loginAsAdmin([
    'access content overview',
    'edit behavior plugin settings',
  ]);
  $edit = [
    'styles[bold][enabled]' => TRUE,
    'styles[italic][enabled]' => FALSE,
    'styles[regular][enabled]' => FALSE,
    'styles[underline][enabled]' => FALSE,
  ];
  $this
    ->drupalGet('admin/reports/paragraphs_collection/styles');
  $this
    ->submitForm($edit, t('Save configuration'));
  $this
    ->addParagraphsType('testplugin');
  $paragraph_type = \Drupal::configFactory()
    ->getEditable('paragraphs.paragraphs_type.testplugin');
  $paragraph_type
    ->set('behavior_plugins.lockable.enabled', TRUE);
  $paragraph_type
    ->set('behavior_plugins.style.enabled', TRUE);
  $paragraph_type
    ->set('behavior_plugins.style.groups.regular_test_group.default', 'bold');
  $paragraph_type
    ->save();
  $this
    ->addFieldtoParagraphType('testplugin', 'field_text', 'text');
  $this
    ->addParagraphedContentType('testcontent', 'testparagraphfield');
  $this
    ->drupalGet('node/add/testcontent');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Add testplugin');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Add testplugin');
  $this
    ->assertSession()
    ->fieldExists('testparagraphfield[0][subform][field_text][0][value]');
  $this
    ->assertSession()
    ->fieldExists('testparagraphfield[1][subform][field_text][0][value]');
  $edit = [
    'title[0][value]' => 'Example title',
  ];
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('testcontent Example title has been created.');
  $this
    ->assertSession()
    ->responseContains('paragraphs-behavior-style--bold');
}