You are here

protected function LingotekParagraphsBulkFormTest::addDemoContent in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  2. 3.0.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  3. 3.1.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  4. 3.2.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  5. 3.3.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  6. 3.4.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  7. 3.5.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  8. 3.6.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  9. 3.7.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
  10. 3.8.x tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekParagraphsBulkFormTest::addDemoContent()
1 call to LingotekParagraphsBulkFormTest::addDemoContent()
LingotekParagraphsBulkFormTest::testParagraphsParentShownOnListing in tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php

File

tests/src/Functional/Form/LingotekParagraphsBulkFormTest.php, line 99

Class

LingotekParagraphsBulkFormTest
Tests the bulk management form integration with Paragraphs.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

protected function addDemoContent() {

  // Create three paragraphs to structure the content.
  $paragraph = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => [
      'value' => '<h2>Paragraphs is the new way of content creation!</h2>
      <p>It allows you — Site Builders — to make things cleaner so that you can give more editing power to your end-users.
      Instead of putting all their content in one WYSIWYG body field including images and videos, end-users can now choose on-the-fly between pre-defined Paragraph Types independent from one another. Paragraph Types can be anything you want from a simple text block or image to a complex and configurable slideshow.</p>',
      'format' => 'basic_html',
    ],
  ]);
  $paragraph
    ->save();
  $paragraph2 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => [
      'value' => '<p>This demo creates some default Paragraph types from which you can easily create some content (Nested Paragraph, Text, Image + Text, Text + Image, Image and User). It also includes some basic styling and assures that the content is responsive on any device.</p>',
      'format' => 'basic_html',
    ],
  ]);
  $paragraph2
    ->save();
  $paragraph3 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => [
      'value' => '<p>Apart from the included Paragraph types, you can create your own simply by going to Structure -> Paragraphs types.</p>',
      'format' => 'basic_html',
    ],
  ]);
  $paragraph3
    ->save();
  $paragraph4 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => [
      'value' => '<p>A search api example can be found <a href="/paragraphs_search">here</a></p>',
      'format' => 'basic_html',
    ],
  ]);
  $paragraph4
    ->save();
  $paragraph5 = Paragraph::create([
    'type' => 'paragraph_container',
    'field_paragraphs_demo' => [
      $paragraph4,
    ],
  ]);
  $paragraph5
    ->save();

  // Add demo content with four paragraphs.
  $node = Node::create([
    'type' => 'paragraphed_content_demo',
    'title' => 'Welcome to the Paragraphs Demo module!',
    'langcode' => 'en',
    'uid' => '0',
    'status' => 1,
    'field_paragraphs_demo' => [
      $paragraph,
      $paragraph2,
      $paragraph3,
      $paragraph5,
    ],
  ]);
  $node
    ->save();
  $paragraph6 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => [
      'value' => 'This is content from the library. We can reuse it multiple times without duplicating it.',
      'format' => 'plain_text',
    ],
  ]);
  $paragraph6
    ->save();
  $node = Node::create([
    'type' => 'paragraphed_content_demo',
    'title' => 'Library item',
    'field_paragraphs_demo' => [
      $paragraph6,
    ],
  ]);
  $node
    ->save();
}