3 namespace Drupal\paragraphs\Tests\Experimental;
6 * Tests paragraphs types.
10 class ParagraphsExperimentalTypesTest extends ParagraphsExperimentalTestBase {
13 * Tests the deletion of Paragraphs types.
15 public function testRemoveTypesWithContent() {
16 $this->loginAsAdmin();
17 // Add a Paragraphed test content.
18 $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 $edit = ['title[0][value]' => 'test_node'];
33 $this->drupalPostForm(NULL, $edit, t('Save'));
34 $this->assertText('paragraphed_test test_node has been created.');
36 // Attempt to delete the paragraph type already used.
37 $this->drupalGet('admin/structure/paragraphs_type');
38 $this->clickLink(t('Delete'));
39 $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.');
43 * Tests creating paragraph type.
45 public function testCreateParagraphType() {
46 $this->loginAsAdmin();
48 // Add a paragraph type.
49 $this->drupalGet('/admin/structure/paragraphs_type/add');
51 // Create a paragraph type with label and id more than 32 characters.
54 'id' => 'test_name_with_more_than_32_characters'
56 $this->drupalPostForm(NULL, $edit, 'Save and manage fields');
57 $this->assertNoErrorsLogged();
58 $this->assertText('Machine-readable name cannot be longer than 32 characters but is currently 38 characters long.');
59 $edit['id'] = 'new_test_id';
60 $this->drupalPostForm(NULL, $edit, 'Save and manage fields');
61 $this->assertText('Saved the Test Paragraphs type.');