3 namespace Drupal\paragraphs\Tests\Classic;
6 * Tests paragraphs types.
10 class ParagraphsTypesTest extends ParagraphsTestBase {
13 * Tests the deletion of Paragraphs types.
15 public function testRemoveTypesWithContent() {
16 $this->loginAsAdmin();
18 // Add a Paragraphed test content.
19 $this->addParagraphedContentType('paragraphed_test', 'paragraphs');
20 $this->addParagraphsType('paragraph_type_test');
21 $this->addParagraphsType('text');
23 // Attempt to delete the content type not used yet.
24 $this->drupalGet('admin/structure/paragraphs_type');
25 $this->clickLink(t('Delete'));
26 $this->assertText('This action cannot be undone.');
27 $this->clickLink(t('Cancel'));
29 // Add a test node with a Paragraph.
30 $this->drupalGet('node/add/paragraphed_test');
31 $this->drupalPostAjaxForm(NULL, [], 'paragraphs_paragraph_type_test_add_more');
32 $this->drupalPostForm(NULL, ['title[0][value]' => 'test_node'], t('Save and publish'));
33 $this->assertText('paragraphed_test test_node has been created.');
35 // Attempt to delete the paragraph type already used.
36 $this->drupalGet('admin/structure/paragraphs_type');
37 $this->clickLink(t('Delete'));
38 $this->assertText('paragraph_type_test Paragraphs type is used by 1 piece of content on your site. You can not remove this paragraph_type_test Paragraphs type until you have removed all from the content.');