You are here

protected function LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  2. 3.0.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  3. 3.1.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  4. 3.2.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  5. 3.3.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  6. 3.4.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  7. 3.5.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  8. 3.6.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  9. 3.7.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
  10. 3.8.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
3 calls to LingotekNodeNestedParagraphsTranslationTest::createNestedParagraphedNode()
LingotekNodeNestedParagraphsTranslationTest::testParagraphEditsAreKeptWhenTranslating in tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php
LingotekNodeNestedParagraphsTranslationTest::testParagraphedNodeDownloadDoesntChangeReferencesOnSource in tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php
Tests that paragraph references aren't removed on download.
LingotekNodeNestedParagraphsTranslationTest::testParagraphRevisionsAreKeptWhenTranslating in tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php

File

tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php, line 687

Class

LingotekNodeNestedParagraphsTranslationTest
Tests translating a node with multiple locales including nested paragraphs.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function createNestedParagraphedNode($profile = 'manual') {
  $nestedParagraph1 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => 'Llamas are very cool for the first time',
  ]);
  $nestedParagraph1
    ->save();
  $nestedParagraph2 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => 'Llamas are very cool for the second time',
  ]);
  $nestedParagraph2
    ->save();
  $paragraph1 = Paragraph::create([
    'type' => 'paragraph_container',
    'field_paragraphs_demo' => [
      $nestedParagraph1,
      $nestedParagraph2,
    ],
  ]);
  $paragraph1
    ->save();
  $nestedParagraph3 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => 'Dogs are very cool for the first time',
  ]);
  $nestedParagraph3
    ->save();
  $nestedParagraph4 = Paragraph::create([
    'type' => 'image_text',
    'field_text_demo' => 'Dogs are very cool for the second time',
  ]);
  $nestedParagraph4
    ->save();
  $paragraph2 = Paragraph::create([
    'type' => 'paragraph_container',
    'field_paragraphs_demo' => [
      $nestedParagraph3,
      $nestedParagraph4,
    ],
  ]);
  $paragraph2
    ->save();
  $metadata = LingotekContentMetadata::create([
    'profile' => $profile,
  ]);
  $metadata
    ->save();
  $node = Node::create([
    'type' => 'paragraphed_nested_content',
    'title' => 'Llamas are cool',
    'lingotek_metadata' => $metadata,
    'field_paragraph_container' => [
      $paragraph1,
      $paragraph2,
    ],
    'status' => TRUE,
  ]);
  $node
    ->save();
}