773439efc28ffe804e8758b6b3314bde288fae8c
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Experimental / ParagraphsExperimentalTypesTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Experimental;
4
5 /**
6  * Tests paragraphs types.
7  *
8  * @group paragraphs
9  */
10 class ParagraphsExperimentalTypesTest extends ParagraphsExperimentalTestBase {
11
12   /**
13    * Tests the deletion of Paragraphs types.
14    */
15   public function testRemoveTypesWithContent() {
16     $this->loginAsAdmin();
17     // Add a Paragraphed test content.
18     $this->addParagraphedContentType('paragraphed_test', 'paragraphs');
19
20     $this->addParagraphsType('paragraph_type_test');
21     $this->addParagraphsType('text');
22
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'));
28
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.');
34
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.');
39   }
40
41 }