public function ParagraphsConfigTest::testIncludedParagraphTypes

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsConfigTest::testIncludedParagraphTypes()
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsConfigTest::testIncludedParagraphTypes()

Test included Paragraph types.

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php, line 172

Class

ParagraphsConfigTest
Tests paragraphs configuration.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

Code

public function testIncludedParagraphTypes() {
  $this
    ->loginAsAdmin();

  // Add a Paragraph content type and 2 Paragraphs types.
  $this
    ->addParagraphedContentType('paragraphed_test', 'paragraphs');
  $this
    ->addParagraphsType('paragraph_type_test');
  $this
    ->addParagraphsType('text');
  $this
    ->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs');
  $edit = [
    'settings[handler_settings][negate]' => '0',
    'settings[handler_settings][target_bundles_drag_drop][paragraph_type_test][enabled]' => '1',
  ];
  $this
    ->submitForm($edit, 'Save settings');
  $this
    ->assertSession()
    ->pageTextContains('Saved paragraphs configuration.');
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->assertSession()
    ->buttonExists('Add paragraph_type_test');
  $this
    ->assertSession()
    ->responseNotContains('Add text');
  $edit = [
    'title[0][value]' => 'Testing included types',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('paragraphed_test Testing included types has been created.');

  // Include all types.
  $this
    ->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs');
  $edit = [
    'settings[handler_settings][negate]' => '0',
    'settings[handler_settings][target_bundles_drag_drop][text][enabled]' => '1',
    'settings[handler_settings][target_bundles_drag_drop][paragraph_type_test][enabled]' => '1',
  ];
  $this
    ->submitForm($edit, 'Save settings');
  $this
    ->drupalGet('node/add/paragraphed_test');
  $button_paragraphed_type_test = $this
    ->xpath('//input[@id=:id]', [
    ':id' => 'paragraphs-paragraph-type-test-add-more',
  ]);
  $button_text = $this
    ->xpath('//input[@id=:id]', [
    ':id' => 'paragraphs-text-add-more',
  ]);
  $this
    ->assertNotNull($button_paragraphed_type_test);
  $this
    ->assertNotNull($button_text);
  $edit = [
    'title[0][value]' => 'Testing all excluded types',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('paragraphed_test Testing all excluded types has been created.');
}