You are here

public function MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit in Inline Entity Form 7

Tests the entity creation with different bundles nested in each other.

ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3

File

tests/multiple_values_widget.test, line 219

Class

MultipleValuesWidgetTest
IEF multiple values field widget tests.

Code

public function testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit() {
  $required_possibilities = array(
    FALSE,
    TRUE,
  );
  foreach ($required_possibilities as $required) {
    $this
      ->setupNestedMultipleForm($required);
    $nested3_title = 'nested3 title single ' . ($required ? 'required' : 'not required');
    $nested2_title = 'nested2 title single ' . ($required ? 'required' : 'not required');
    $nested1_title = 'nested1 title single ' . ($required ? 'required' : 'not required');
    $edit = array(
      'title' => $nested1_title,
      'field_test_ref_nested1[und][form][title]' => $nested2_title,
      'field_test_ref_nested1[und][form][field_test_ref_nested2][und][form][title]' => $nested3_title,
    );
    $this
      ->drupalPost(NULL, $edit, t('Save'));
    $nested1_node = $this
      ->drupalGetNodeByTitle($nested1_title);
    $this
      ->assertEqual($nested1_title, $nested1_node->title, "First node's title looks correct.");
    $this
      ->assertEqual('ief_test_nested1', $nested1_node->type, "First node's type looks correct.");
    $creatednested2 = node_load($nested1_node->field_test_ref_nested1[LANGUAGE_NONE][0]['target_id']);
    $this
      ->assertEqual($nested2_title, $creatednested2->title, "Second node's title looks correct.");
    $this
      ->assertEqual('ief_test_nested2', $creatednested2->type, "Second node's type looks correct.");
    $creatednested3 = node_load($creatednested2->field_test_ref_nested2[LANGUAGE_NONE][0]['target_id']);
    $this
      ->assertEqual($nested3_title, $creatednested3->title, "Third node's title looks correct.");
    $this
      ->assertEqual('ief_test_nested3', $creatednested3->type, "Third node's type looks correct.");
    $this
      ->checkNestedEntityEditing($nested1_node, FALSE);
  }
}