Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Classic / ParagraphsSummaryFormatterTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Classic;
4
5 use Drupal\field_ui\Tests\FieldUiTestTrait;
6
7 /**
8  * Tests the paragraphs summary formatter.
9  *
10  * @group paragraphs
11  */
12 class ParagraphsSummaryFormatterTest extends ParagraphsTestBase {
13
14   use FieldUiTestTrait;
15
16   /**
17    * Modules to enable.
18    *
19    * @var array
20    */
21   public static $modules = [
22     'image',
23   ];
24
25   /**
26    * Tests the paragraphs summary formatter.
27    */
28   public function testParagraphsSummaryFormatter() {
29     $this->addParagraphedContentType('paragraphed_test', 'field_paragraphs', 'entity_reference_paragraphs');
30     $this->loginAsAdmin(['create paragraphed_test content', 'edit any paragraphed_test content', 'administer node display']);
31
32     // Add a Paragraph type.
33     $paragraph_type = 'text_paragraph';
34     $this->addParagraphsType($paragraph_type);
35     $title_paragraphs_type = 'title';
36     $this->addParagraphsType($title_paragraphs_type);
37     $this->addParagraphsType('text');
38     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
39     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $title_paragraphs_type, 'title', 'Title', 'string', [], []);
40
41     // Add a user Paragraph Type
42     $paragraph_type = 'user_paragraph';
43     $this->addParagraphsType($paragraph_type);
44     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'user', 'User', 'entity_reference', ['settings[target_type]' => 'user'], []);
45
46     // Set display format to paragraphs summary.
47     $this->drupalGet('admin/structure/types/manage/paragraphed_test/display');
48     $edit = ['fields[field_paragraphs][type]' => 'paragraph_summary'];
49     $this->drupalPostForm(NULL, $edit, t('Save'));
50     // Add a paragraph.
51     $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'field_paragraphs_text_paragraph_add_more');
52     $this->drupalPostAjaxForm(NULL, NULL, 'field_paragraphs_title_add_more');
53
54     // Create a node with a text.
55     $edit = [
56       'title[0][value]' => 'Test article',
57       'field_paragraphs[0][subform][field_text][0][value]' => 'text_summary',
58       'field_paragraphs[1][subform][field_title][0][value]' => 'Title example',
59     ];
60     $this->drupalPostForm(NULL, $edit, t('Save'));
61     $this->clickLink(t('Edit'));
62     $this->drupalPostForm(NULL, [], t('Add user_paragraph'));
63     $edit = [
64       'field_paragraphs[2][subform][field_user][0][target_id]' => $this->admin_user->label() . ' (' . $this->admin_user->id() . ')',
65     ];
66     $this->drupalPostForm(NULL, $edit, t('Save'));
67
68     // Assert the summary is correctly generated.
69     $this->assertText($this->admin_user->label());
70     $this->assertText('Title example');
71
72   }
73
74 }