You are here

public function ParagraphsSliderPluginTest::testConfigurationForm in Paragraphs Collection 8

Tests configuration form for slider plugin.

File

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

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
    ->drupalPostForm(NULL, $edit, t('Save and continue'));
  $edit = [
    'cardinality' => '-1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save field settings'));
  $this
    ->assertText('Updated field Text field settings');
  $this
    ->drupalPostForm(NULL, NULL, t('Save settings'));
  $this
    ->assertText('Saved Text configuration');

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

  // Add slider content.
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->drupalPostForm(NULL, NULL, 'field_paragraphs_slider_add_more');
  $this
    ->drupalPostForm(NULL, NULL, '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
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertText('paragraphed_test SldierDemo has been created.');
}