Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Classic / ParagraphsUiTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Classic;
4
5 use Drupal\field_ui\Tests\FieldUiTestTrait;
6
7 /**
8  * Tests the Paragraphs user interface.
9  *
10  * @group paragraphs
11  */
12 class ParagraphsUiTest extends ParagraphsTestBase {
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_name = 'content';
41     $field_title = 'Content Test';
42     $field_type = 'field_ui:entity_reference_revisions:paragraph';
43     $field_edit = [
44       'required' => TRUE,
45     ];
46     $this->fieldUIAddNewField($bundle_path, $field_name, $field_title, $field_type, [], $field_edit);
47
48     $form_display_edit = [
49       'fields[field_content][type]' => 'entity_reference_paragraphs',
50     ];
51     $this->drupalPostForm($bundle_path . '/form-display', $form_display_edit, t('Save'));
52
53     // Attempt to create a paragraphed node with an empty required field.
54     $title = 'Empty';
55     $this->drupalGet('node/add/paragraphed_content_demo');
56     $this->drupalPostForm(NULL, ['title[0][value]' => $title], t('Save'));
57     $this->assertText($field_title . ' field is required');
58
59     // Attempt to create a paragraphed node with only a paragraph in the
60     // "remove" mode in the required field.
61     $title = 'Remove mode';
62     $this->drupalGet('node/add/paragraphed_content_demo');
63     $this->drupalPostAjaxForm(NULL, [], 'field_content_image_text_add_more');
64     $this->drupalPostAjaxForm(NULL, [], 'field_content_0_remove');
65     $this->assertNoText($field_title . ' field is required');
66     $this->drupalPostForm(NULL, ['title[0][value]' => $title], t('Save'));
67     $this->assertText($field_title . ' field is required');
68   }
69
70 }