You are here

protected function ParagraphsNodeMigrationAssertionsTrait::assertNode9Paragraphs in Paragraphs 8

Assertions of node 9.

2 calls to ParagraphsNodeMigrationAssertionsTrait::assertNode9Paragraphs()
MigrateUiParagraphsTest::testParagraphsMigrate in tests/src/Functional/Migrate/MigrateUiParagraphsTest.php
Tests the result of the paragraphs migration.
ParagraphContentMigrationTest::testParagraphContentMigration in tests/src/Kernel/migrate/ParagraphContentMigrationTest.php
Tests the migration of a content with paragraphs and field collections.

File

tests/src/Traits/ParagraphsNodeMigrationAssertionsTrait.php, line 46

Class

ParagraphsNodeMigrationAssertionsTrait

Namespace

Drupal\Tests\paragraphs\Traits

Code

protected function assertNode9Paragraphs() {
  $node_9 = Node::load(9);
  assert($node_9 instanceof NodeInterface);
  if ($this->container
    ->get('module_handler')
    ->moduleExists('content_translation') && $node_9 instanceof TranslatableInterface) {

    // Test the default translation.
    $node_9 = $node_9
      ->getUntranslated();
    $this
      ->assertSame('en', $node_9
      ->language()
      ->getId());
  }

  // Check 'field collection test' field.
  $node_9_field_collection_field_entities = $this
    ->getReferencedEntities($node_9, 'field_field_collection_test', 1);
  $this
    ->assertEquals('Field Collection Text Data Two EN', $node_9_field_collection_field_entities[0]->field_text->value);
  $this
    ->assertEquals('2', $node_9_field_collection_field_entities[0]->field_integer_list->value);

  // Check 'any paragraph' field.
  $node_9_field_any_paragraph_entities = $this
    ->getReferencedEntities($node_9, 'field_any_paragraph', 2);
  $this
    ->assertEquals('Paragraph Field One Bundle One EN', $node_9_field_any_paragraph_entities[0]->field_text->value);
  $this
    ->assertEquals('Some Text', $node_9_field_any_paragraph_entities[0]->field_text_list->value);
  $this
    ->assertEquals('Paragraph Field One Bundle Two EN', $node_9_field_any_paragraph_entities[1]->field_text->value);
  $this
    ->assertEquals('jose@jose.com', $node_9_field_any_paragraph_entities[1]->field_email->value);

  // Check 'paragraph one only' field.
  $node_9_field_paragraph_one_only_entities = $this
    ->getReferencedEntities($node_9, 'field_paragraph_one_only', 1);
  $this
    ->assertEquals('Paragraph Field Two Bundle One EN', $node_9_field_paragraph_one_only_entities[0]->field_text->value);
  $this
    ->assertEquals('Some Text', $node_9_field_paragraph_one_only_entities[0]->field_text_list->value);

  // The 'nested fc outer' field should be empty.
  $this
    ->getReferencedEntities($node_9, 'field_nested_fc_outer', 0);
}