You are here

public function ParagraphsSliderPluginTest::testSliderSettingsSummary in Paragraphs Collection 8

Tests configuration of slider plugin.

File

modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsSliderPluginTest.php, line 151

Class

ParagraphsSliderPluginTest
Tests Slider plugin.

Namespace

Drupal\Tests\paragraphs_collection_demo\Functional

Code

public function testSliderSettingsSummary() {
  $this
    ->loginAsAdmin([
    'create paragraphed_test content',
    'edit any paragraphed_test content',
    'edit behavior plugin settings',
  ]);

  // Add a slide_content paragraph type.
  $this
    ->fieldUIAddExistingField('admin/structure/paragraphs_type/slide_content', 'paragraphs_text', 'slide_content');
  $this
    ->setParagraphsWidgetMode('paragraphed_test', 'field_paragraphs', 'closed');

  // Node edit: add three slides paragraph type.
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->drupalPostForm(NULL, NULL, 'field_paragraphs_slider_add_more');
  $this
    ->drupalPostForm(NULL, NULL, 'field_paragraphs_0_subform_field_slides_slide_content_add_more');
  $this
    ->drupalPostForm(NULL, NULL, 'field_paragraphs_0_subform_field_slides_text_add_more');
  $edit = [
    'title[0][value]' => 'Slider plugin summary',
    'field_paragraphs[0][subform][field_slides][0][subform][paragraphs_text][0][value]' => 'First slide',
    'field_paragraphs[0][subform][field_slides][1][subform][paragraphs_text][0][value]' => 'Second slide',
    'field_paragraphs[0][behavior_plugins][slider][slick_slider]' => 'default',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertText('paragraphed_test Slider plugin summary has been created.');

  // Assert that the summary includes the text of the behavior plugins.
  $this
    ->clickLink('Edit');
  $this
    ->assertRaw('<span class="summary-content">First slide</span>, <span class="summary-content">Second slide</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Slider settings</span>Default');
  $this
    ->assertFieldByXPath('//*[@id="edit-field-paragraphs-0-top-icons"]/span[@class="paragraphs-badge" and @title="2 children"]');
}