You are here

protected function ComplexWidgetTest::checkNestedNodes in Inline Entity Form 8

Checks if nested nodes for ief_test_nested1 content are created.

Parameters

\Drupal\node\NodeInterface $top_level_node: The top level node.

\Drupal\node\NodeInterface $nested_node: The second level node.

\Drupal\node\NodeInterface $double_nested_node: The the third level node.

2 calls to ComplexWidgetTest::checkNestedNodes()
ComplexWidgetTest::testNestedEntityCreationWithDifferentBundlesAjaxSubmit in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests the entity creation with different bundles nested in each other.
ComplexWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests the entity creation with different bundles nested in each other.

File

tests/src/FunctionalJavascript/ComplexWidgetTest.php, line 876

Class

ComplexWidgetTest
IEF complex field widget tests.

Namespace

Drupal\Tests\inline_entity_form\FunctionalJavascript

Code

protected function checkNestedNodes(NodeInterface $top_level_node, NodeInterface $nested_node, NodeInterface $double_nested_node) {

  // Check the type and title of the second level node.
  if ($nested_node
    ->id() == $top_level_node->test_ref_nested1->entity
    ->id()) {
    $this
      ->assertEquals(1, $top_level_node->test_ref_nested1
      ->count(), 'Only one nested node created');
    $this
      ->assertSame($top_level_node->test_ref_nested1->entity
      ->label(), $nested_node
      ->label(), "Nested node's title is correct.");
    $this
      ->assertSame('ief_test_nested2', $nested_node
      ->bundle(), "Nested node's type is correct.");

    // Check the type and title of the third level node.
    if ($double_nested_node
      ->id() == $nested_node->test_ref_nested2->entity
      ->id()) {
      $this
        ->assertEquals(1, $nested_node->test_ref_nested2
        ->count(), 'Only one node within a node within a node created.');
      $this
        ->assertSame($nested_node->test_ref_nested2->entity
        ->label(), $double_nested_node
        ->label(), "Node within a node within a node's title is correct.");
      $this
        ->assertSame('ief_test_nested3', $double_nested_node
        ->bundle(), "Node within a node within a node's type is correct.");
      $this
        ->checkNestedNodeEditing($top_level_node);
    }
  }
}