public function ParagraphsBackgroundPluginTest::testNoImageField

Tests the functionality when there are no image fields in a paragraph type.

File

paragraphs_collection/modules/paragraphs_collection_demo/tests/src/Functional/ParagraphsBackgroundPluginTest.php, line 137

Class

ParagraphsBackgroundPluginTest
Tests the background plugin.

Namespace

Drupal\Tests\paragraphs_collection_demo\Functional

Code

public function testNoImageField() {

  // Create an article with paragraphs field.
  $this
    ->addParagraphedContentType('article', 'paragraphs');
  $this
    ->loginAsAdmin();

  // Add a text paragraphs type without any field.
  $this
    ->addParagraphsType('text_test');
  $edit = [
    'behavior_plugins[background][enabled]' => TRUE,
  ];

  // Assert that the error messages are displayed.
  $this
    ->drupalGet('admin/structure/paragraphs_type/text_test');
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->responseContains('The Background plugin cannot be enabled without an image field.');
  $this
    ->assertSession()
    ->pageTextContains('No image field type available. Please add at least one in the Manage fields page.');
}