Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Classic / ParagraphsPreviewTest.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Classic;
4
5 use Drupal\field_ui\Tests\FieldUiTestTrait;
6
7 /**
8  * Tests the configuration of paragraphs.
9  *
10  * @group paragraphs
11  */
12 class ParagraphsPreviewTest extends ParagraphsTestBase {
13
14   use FieldUiTestTrait;
15
16   /**
17    * Modules to enable.
18    *
19    * @var array
20    */
21   public static $modules = array(
22     'image',
23   );
24
25   /**
26    * Tests the revision of paragraphs.
27    */
28   public function testParagraphsPreview() {
29     // Create paragraph type Headline + Block.
30     $this->addParagraphedContentType('article', 'field_paragraphs', 'entity_reference_paragraphs');
31     $this->loginAsAdmin([
32       'administer node display',
33       'create article content',
34       'edit any article content',
35       'delete any article content',
36     ]);
37
38     // Create paragraph type Headline + Block.
39     $this->addParagraphsType('text');
40     // Create field types for the text.
41     $this->fieldUIAddNewField('admin/structure/paragraphs_type/text', 'text', 'Text', 'text', array(), array());
42     $this->assertText('Saved Text configuration.');
43
44     $test_text_1 = 'dummy_preview_text_1';
45     $test_text_2 = 'dummy_preview_text_2';
46     // Create node with two paragraphs.
47     $this->drupalGet('node/add/article');
48     $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more');
49     // Set the value of the paragraphs.
50     $edit = [
51       'title[0][value]' => 'Page_title',
52       'field_paragraphs[0][subform][field_text][0][value]' => $test_text_1,
53     ];
54     // Preview the article.
55     $this->drupalPostForm(NULL, $edit, t('Preview'));
56     // Check if the text is displayed.
57     $this->assertRaw($test_text_1);
58
59     // Go back to the editing form.
60     $this->clickLink('Back to content editing');
61
62     $paragraph_1 = $this->xpath('//*[@id="edit-field-paragraphs-0-subform-field-text-0-value"]')[0];
63     $this->assertEqual($paragraph_1['value'], $test_text_1);
64
65     $this->drupalPostForm(NULL, $edit, t('Save'));
66
67     $this->clickLink('Edit');
68     $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more');
69     $edit = [
70       'field_paragraphs[1][subform][field_text][0][value]' => $test_text_2,
71     ];
72     // Preview the article.
73     $this->drupalPostForm(NULL, $edit, t('Preview'));
74     $this->assertRaw($test_text_1);
75     $this->assertRaw($test_text_2);
76
77     // Go back to the editing form.
78     $this->clickLink('Back to content editing');
79     $new_test_text_2 = 'less_dummy_preview_text_2';
80
81     $edit = [
82       'field_paragraphs[1][subform][field_text][0][value]' => $new_test_text_2,
83     ];
84     // Preview the article.
85     $this->drupalPostForm(NULL, $edit, t('Preview'));
86     $this->assertRaw($test_text_1);
87     $this->assertRaw($new_test_text_2);
88     // Go back to the editing form.
89     $this->clickLink('Back to content editing');
90     $paragraph_1 = $this->xpath('//*[@id="edit-field-paragraphs-0-subform-field-text-0-value"]')[0];
91     $paragraph_2 = $this->xpath('//*[@id="edit-field-paragraphs-1-subform-field-text-0-value"]')[0];
92     $this->assertEqual($paragraph_1['value'], $test_text_1);
93     $this->assertEqual($paragraph_2['value'], $new_test_text_2);
94     $this->drupalPostForm(NULL, [], t('Save'));
95
96     $this->assertRaw($test_text_1);
97     $this->assertRaw($new_test_text_2);
98     $this->assertRaw('Page_title');
99   }
100
101 }