Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / paragraphs / modules / paragraphs_demo / src / Tests / ParagraphsDemoTest.php
index 54fc7251ebbb85ddf4cb86e0b4462df73fa644d1..16f9701a62bc3961336c9a014001f0f3899f4daa 100644 (file)
@@ -3,6 +3,7 @@
 namespace Drupal\paragraphs_demo\Tests;
 
 use Drupal\filter\Entity\FilterFormat;
+use Drupal\paragraphs\Tests\Classic\ParagraphsCoreVersionUiTestTrait;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -12,6 +13,8 @@ use Drupal\simpletest\WebTestBase;
  */
 class ParagraphsDemoTest extends WebTestBase {
 
+  use ParagraphsCoreVersionUiTestTrait;
+
   /**
    * Modules to enable.
    *
@@ -43,7 +46,6 @@ class ParagraphsDemoTest extends WebTestBase {
     $basic_html_format->save();
     $admin_user = $this->drupalCreateUser(array(
       'administer site configuration',
-      'administer nodes',
       'create paragraphed_content_demo content',
       'edit any paragraphed_content_demo content',
       'delete any paragraphed_content_demo content',
@@ -62,6 +64,13 @@ class ParagraphsDemoTest extends WebTestBase {
     ));
 
     $this->drupalLogin($admin_user);
+
+    // Set edit mode to open.
+    $this->drupalGet('admin/structure/types/manage/paragraphed_content_demo/form-display');
+    $this->drupalPostAjaxForm(NULL, [], "field_paragraphs_demo_settings_edit");
+    $edit = ['fields[field_paragraphs_demo][settings_edit_form][settings][edit_mode]' => 'open'];
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+
     // Check for all pre-configured paragraphs_types.
     $this->drupalGet('admin/structure/paragraphs_type');
     $this->assertText('Image + Text');
@@ -105,7 +114,7 @@ class ParagraphsDemoTest extends WebTestBase {
     // Check that title and the descriptions are set.
     $this->drupalGet('admin/structure/types/manage/paragraphed_content_demo');
     $this->assertText('Paragraphed article');
-    $this->assertText('Article with paragraphs.');
+    $this->assertText('Article with Paragraphs.');
 
     // Check that the Paragraph field is added.
     $this->clickLink('Manage fields');
@@ -132,27 +141,26 @@ class ParagraphsDemoTest extends WebTestBase {
     $edit = [
       'field_paragraphs_demo[1][subform][field_user_demo][0][target_id]' => $admin_user->label() . ' (' . $admin_user->id() . ')',
     ];
-    $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+    $this->drupalPostForm(NULL, $edit, t('Save'));
 
     $this->assertText('Paragraphed article Paragraph title has been created.');
     $this->assertText('Paragraph title');
     $this->assertText('Paragraph text');
 
     // Search a nested Paragraph text.
-    /**
-     * @todo Reinstate this after search_api is fixed.
-     *
-     * search_api issue: https://www.drupal.org/node/2792277
-     * paragraphs issue: https://www.drupal.org/node/2791315
     $this->drupalGet('paragraphs_search', ['query' => ['search_api_fulltext' => 'A search api example']]);
     $this->assertRaw('Welcome to the Paragraphs Demo module!');
     // Search a node paragraph field text.
     $this->drupalGet('paragraphs_search', ['query' => ['search_api_fulltext' => 'It allows you']]);
     $this->assertRaw('Welcome to the Paragraphs Demo module!');
-    */
     // Search non existent text.
     $this->drupalGet('paragraphs_search', ['query' => ['search_api_fulltext' => 'foo']]);
     $this->assertNoRaw('Welcome to the Paragraphs Demo module!');
+
+    // Check that the dropbutton of Nested Paragraph has the Duplicate function.
+    // For now, this indicates that it is using the EXPERIMENTAL widget.
+    $this->drupalGet('node/1/edit');
+    $this->assertFieldByName('field_paragraphs_demo_3_subform_field_paragraphs_demo_0_duplicate');
   }
 
 }