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