Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Experimental / ParagraphsExperimentalUiTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Experimental;
4
5 use Drupal\field_ui\Tests\FieldUiTestTrait;
6
7 /**
8  * Tests the Paragraphs user interface.
9  *
10  * @group paragraphs
11  */
12 class ParagraphsExperimentalUiTest extends ParagraphsExperimentalTestBase {
13
14   use FieldUiTestTrait;
15
16   /**
17    * Modules to enable.
18    *
19    * @var array
20    */
21   public static $modules = [
22     'paragraphs_demo',
23   ];
24
25   /**
26    * Tests displaying an error message a required paragraph field that is empty.
27    */
28   public function testEmptyRequiredField() {
29     $admin_user = $this->drupalCreateUser([
30       'administer node fields',
31       'administer paragraph form display',
32       'administer node form display',
33       'create paragraphed_content_demo content',
34       'edit any paragraphed_content_demo content',
35     ]);
36     $this->drupalLogin($admin_user);
37
38     // Add required field to paragraphed content type.
39     $bundle_path = 'admin/structure/types/manage/paragraphed_content_demo';
40     $field_title = 'Content Test';
41     $field_type = 'field_ui:entity_reference_revisions:paragraph';
42     $field_edit = [
43       'required' => TRUE,
44     ];
45     $this->fieldUIAddNewField($bundle_path, 'content', $field_title, $field_type, [], $field_edit);
46
47     $form_display_edit = [
48       'fields[field_content][type]' => 'paragraphs',
49     ];
50     $this->drupalPostForm($bundle_path . '/form-display', $form_display_edit, t('Save'));
51
52     // Attempt to create a paragraphed node with an empty required field.
53     $title = 'Empty';
54     $this->drupalGet('node/add/paragraphed_content_demo');
55     $this->drupalPostForm(NULL, ['title[0][value]' => $title], t('Save'));
56     $this->assertText($field_title . ' field is required');
57
58     // Attempt to create a paragraphed node with only a paragraph in the
59     // "remove" mode in the required field.
60     $title = 'Remove all items';
61     $this->drupalGet('node/add/paragraphed_content_demo');
62     $this->drupalPostAjaxForm(NULL, [], 'field_content_image_text_add_more');
63     $this->drupalPostAjaxForm(NULL, [], 'field_content_0_remove');
64     $this->assertNoText($field_title . ' field is required');
65     $this->drupalPostForm(NULL, ['title[0][value]' => $title], t('Save'));
66     $this->assertText($field_title . ' field is required');
67
68     // Attempt to create a paragraphed node with a valid paragraph and a
69     // removed paragraph.
70     $title = 'Valid Removal';
71     $this->drupalGet('node/add/paragraphed_content_demo');
72     $this->drupalPostAjaxForm(NULL, [], 'field_content_image_text_add_more');
73     $this->drupalPostAjaxForm(NULL, [], 'field_content_image_text_add_more');
74     $this->drupalPostAjaxForm(NULL, [], 'field_content_1_remove');
75     $this->assertNoText($field_title . ' field is required');
76     $this->drupalPostForm(NULL, ['title[0][value]' => $title], t('Save'));
77     $this->assertNoText($field_title . ' field is required');
78   }
79
80 }