Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Experimental / ParagraphsExperimentalSummaryFormatterTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Experimental;
4
5 use Drupal\field_ui\Tests\FieldUiTestTrait;
6
7 /**
8  * Tests the paragraphs summary formatter.
9  *
10  * @group paragraphs
11  */
12 class ParagraphsExperimentalSummaryFormatterTest extends ParagraphsExperimentalTestBase {
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');
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     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
38     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $title_paragraphs_type, 'title', 'Title', 'string', [], []);
39
40     // Add a user Paragraph Type
41     $paragraph_type = 'user_paragraph';
42     $this->addParagraphsType($paragraph_type);
43     static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'user', 'User', 'entity_reference', ['settings[target_type]' => 'user'], []);
44
45     // Set display format to paragraphs summary.
46     $this->drupalGet('admin/structure/types/manage/paragraphed_test/display');
47     $edit = ['fields[field_paragraphs][type]' => 'paragraph_summary'];
48     $this->drupalPostForm(NULL, $edit, t('Save'));
49     // Add a paragraph.
50     $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'field_paragraphs_text_paragraph_add_more');
51     $this->drupalPostAjaxForm(NULL, NULL, 'field_paragraphs_title_add_more');
52
53     // Create a node with a text.
54     $edit = [
55       'title[0][value]' => 'Test article',
56       'field_paragraphs[0][subform][field_text][0][value]' => 'text_summary',
57       'field_paragraphs[1][subform][field_title][0][value]' => 'Title example',
58     ];
59     $this->drupalPostForm(NULL, $edit, t('Save'));
60     $this->clickLink(t('Edit'));
61     $this->drupalPostForm(NULL, [], t('Add user_paragraph'));
62     $edit = [
63       'field_paragraphs[2][subform][field_user][0][target_id]' => $this->admin_user->label() . ' (' . $this->admin_user->id() . ')',
64     ];
65     $this->drupalPostForm(NULL, $edit, t('Save'));
66
67     // Assert the summary is correctly generated.
68     $this->assertText($this->admin_user->label());
69     $this->assertText('Title example');
70   }
71
72 }