You are here

public function ParagraphsStylePluginTest::testNoStylesAvailable in Paragraphs Collection 8

Tests style plugin with no styles available.

File

tests/src/FunctionalJavascript/ParagraphsStylePluginTest.php, line 439

Class

ParagraphsStylePluginTest
Tests the style selection plugin.

Namespace

Drupal\Tests\paragraphs_collection\FunctionalJavascript

Code

public function testNoStylesAvailable() {
  $this
    ->addParagraphedContentType('paragraphed_test', 'paragraphs');
  $this
    ->loginAsAdmin([
    'edit any paragraphed_test content',
    'edit behavior plugin settings',
  ]);
  $this
    ->drupalGet('admin/structure/paragraphs_type/add');

  // Create Paragraph type with Style plugin enabled.
  $paragraph_type = 'test_style_plugin';
  $this
    ->addParagraphsType($paragraph_type);

  // Add a text field.
  $this
    ->fieldUIAddExistingField('admin/structure/paragraphs_type/' . $paragraph_type, 'paragraphs_text', 'paragraphs_text');
  $this
    ->drupalGet('admin/structure/paragraphs_type/' . $paragraph_type);
  $options = $this
    ->xpath('//*[contains(@id,"edit-behavior-plugins-style-settings-groups")]/option');
  $this
    ->assertCount(0, $options);
  $edit = [
    'behavior_plugins[style][enabled]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  // Make sure there is an error message shown for the style group.
  $this
    ->assertSession()
    ->pageTextContains('There is no style group available, the style plugin can not be enabled.');
}