You are here

protected function MultipleValuesWidgetTest::checkNestedEntityEditing in Inline Entity Form 7

Checks that nested IEF entity references can be edit and saved.

Parameters

$node: Top level node of type ief_test_nested1 to check.

bool $ajax_submit: Whether IEF form widgets should be submitted via AJax or left open.

2 calls to MultipleValuesWidgetTest::checkNestedEntityEditing()
MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesAjaxSubmit in tests/multiple_values_widget.test
Tests the entity creation with different bundles nested in each other.
MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit in tests/multiple_values_widget.test
Tests the entity creation with different bundles nested in each other.

File

tests/multiple_values_widget.test, line 652

Class

MultipleValuesWidgetTest
IEF multiple values field widget tests.

Code

protected function checkNestedEntityEditing($node, $ajax_submit = TRUE) {
  $this
    ->drupalGet("node/{$node->nid}/edit");
  $level_1_node = node_load($node->field_test_ref_nested1[LANGUAGE_NONE][0]['target_id']);
  $level_2_node = node_load($level_1_node->field_test_ref_nested2[LANGUAGE_NONE][0]['target_id']);
  $level_2_node_update_title = $level_2_node->title . ' - updated';

  //edit-test-ref-nested1-entities-0-actions-ief-entity-edit
  $this
    ->drupalPostAjax(NULL, array(), $this
    ->getButtonName('//input[@type="submit" and @id="edit-field-test-ref-nested1-und-entities-0-actions-ief-entity-edit"]'));

  //edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-entities-0-actions-ief-entity-edit
  $this
    ->drupalPostAjax(NULL, array(), $this
    ->getButtonName('//input[@type="submit" and @id="edit-field-test-ref-nested1-und-entities-0-form-field-test-ref-nested2-und-entities-0-actions-ief-entity-edit"]'));
  $edit['field_test_ref_nested1[und][entities][0][form][field_test_ref_nested2][und][entities][0][form][title]'] = $level_2_node_update_title;
  if ($ajax_submit) {

    // Close IEF Forms with AJAX posts

    //edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-form-inline-entity-form-entities-0-form-actions-ief-edit-save
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @id="edit-field-test-ref-nested1-und-entities-0-form-field-test-ref-nested2-und-entities-0-form-actions-ief-edit-save"]'));
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @id="edit-field-test-ref-nested1-und-entities-0-form-actions-ief-edit-save"]'));
    $this
      ->drupalPost(NULL, array(), t('Save'));
  }
  else {
    $this
      ->drupalPost(NULL, $edit, t('Save'));
  }
  $level_2_node = node_load($level_2_node->nid, NULL, TRUE);
  $this
    ->assertEqual($level_2_node_update_title, $level_2_node->title);
}