public function ParagraphsSliderPluginTest::testConfigurationForm

Tests configuration form for slider plugin.

File

paragraphs_collection/modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsSliderPluginTest.php, line 84

Class

ParagraphsSliderPluginTest
Tests Slider plugin.

Namespace

Drupal\Tests\paragraphs_collection_demo\Functional

Code

public function testConfigurationForm() {

  //Add a new field
  $this
    ->drupalGet('admin/structure/paragraphs_type/slider/fields/add-field');
  $edit = [
    'new_storage_type' => 'text_long',
    'label' => 'Text',
    'field_name' => 'paragraphs_text',
  ];
  $this
    ->submitForm($edit, t('Save and continue'));
  $edit = [
    'cardinality' => '-1',
  ];
  $this
    ->submitForm($edit, t('Save field settings'));
  $this
    ->assertSession()
    ->pageTextContains('Updated field Text field settings');
  $this
    ->submitForm([], t('Save settings'));
  $this
    ->assertSession()
    ->pageTextContains('Saved Text configuration');

  //Choose the field to be used as slider items
  $this
    ->drupalGet('admin/structure/paragraphs_type/slider');
  $this
    ->assertSession()
    ->pageTextContains('Slick Optionsets');
  $this
    ->assertSession()
    ->pageTextContains('Enable the Slick UI from the module list to create more options.');
  $edit = [
    'behavior_plugins[slider][settings][field_name]' => 'field_paragraphs_text',
  ];
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('Saved the Slider Paragraphs type.');

  // Add slider content.
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->submitForm([], 'field_paragraphs_slider_add_more');
  $this
    ->submitForm([], 'field_paragraphs_text_add_more');
  $edit = [
    'title[0][value]' => 'SldierDemo',
    'field_paragraphs[0][subform][field_paragraphs_text][0][value]' => 'First slide.',
    'field_paragraphs[1][subform][paragraphs_text][0][value]' => 'Second slide',
    'field_paragraphs[0][behavior_plugins][slider][slick_slider]' => 'default',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('paragraphed_test SldierDemo has been created.');
}