Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Experimental / ParagraphsExperimentalInlineEntityFormTest.php
index 653da465f05320c2325271687c646d1bfb1edd5c..1ddd6189bbeaf739449a357cab0525fc81fba8d9 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Drupal\paragraphs\Tests\Experimental;
 
+use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait;
+
 /**
  * Tests the configuration of paragraphs in relation to ief.
  *
@@ -9,6 +11,8 @@ namespace Drupal\paragraphs\Tests\Experimental;
  */
 class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalTestBase {
 
+  use ParagraphsTestBaseTrait;
+
   /**
    * Modules to enable.
    *
@@ -23,7 +27,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
    */
   public function testParagraphsIEFPreview() {
     // Create article content type with a paragraphs field.
-    $this->addParagraphedContentType('article', 'field_paragraphs');
+    $this->addParagraphedContentType('article');
     $this->loginAsAdmin(['create article content', 'edit any article content']);
 
     // Create the paragraphs type simple.
@@ -47,8 +51,13 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
 
-    // Set the paragraphs widget mode to preview.
-    $this->setParagraphsWidgetMode('article', 'field_paragraphs', 'preview');
+    // Set the paragraphs widget edit mode to "Closed" and the closed mode to
+    // "Preview".
+    $settings = [
+      'edit_mode' => 'closed',
+      'closed_mode' => 'preview',
+    ];
+    $this->setParagraphsWidgetSettings('article', 'field_paragraphs', $settings);
 
     // Create node with one paragraph.
     $this->drupalGet('node/add/article');
@@ -59,7 +68,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
       'title[0][value]' => 'Dummy1',
       'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Dummy2',
     ];
-    $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+    $this->drupalPostForm(NULL, $edit, t('Save'));
 
     // Go back into edit page.
     $node = $this->getNodeByTitle('Dummy1');
@@ -74,7 +83,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
    */
   public function testParagraphsIEFChangeOrder() {
     // Create article content type with a paragraphs field.
-    $this->addParagraphedContentType('article', 'field_paragraphs');
+    $this->addParagraphedContentType('article');
     $this->loginAsAdmin(['create article content', 'edit any article content']);
 
     // Create the paragraphs type simple.
@@ -107,8 +116,8 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
 
-    // Set the paragraphs widget mode to preview.
-    $this->setParagraphsWidgetMode('article', 'field_paragraphs', 'preview');
+    // Set the paragraphs widget closed mode to preview.
+    $this->setParagraphsWidgetSettings('article', 'field_paragraphs', ['closed_mode' => 'preview']);
 
     // Create node with one paragraph.
     $this->drupalGet('node/add/article');
@@ -120,7 +129,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
       'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic page 1',
     ];
 
-    $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+    $this->drupalPostForm(NULL, $edit, t('Save'));
 
     // Go back into edit page.
     $node = $this->getNodeByTitle('Article 1');
@@ -129,13 +138,11 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT
     // Create second paragraph.
     $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_simple_add_more');
 
-    // Set the values of second paragraph and change the order.
+    // Set the values of second paragraph.
     $edit = [
-      'field_paragraphs[1][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic 2',
-      'field_paragraphs[0][_weight]' => -1,
-      'field_paragraphs[1][_weight]' => -2,
+      'field_paragraphs[1][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic 2'
     ];
-    $this->drupalPostForm(NULL, $edit, t('Save and keep published'));
+    $this->drupalPostForm(NULL, $edit, t('Save'));
   }
 
 }