You are here

class MultipleValuesWidgetTest in Inline Entity Form 7

IEF multiple values field widget tests.

@group inline_entity_form

Hierarchy

Expanded class hierarchy of MultipleValuesWidgetTest

File

tests/multiple_values_widget.test, line 8

View source
class MultipleValuesWidgetTest extends InlineEntityFormTestBase {

  /**
   * URL to add new content.
   *
   * @var string
   */
  protected $formContentAddUrl;
  public static function getInfo() {
    return array(
      'name' => 'Multiple values widget',
      'description' => 'Tests the "Inline Entity Form" multiple values widget.',
      'group' => 'Inline entity form',
    );
  }
  protected function setUp() {
    $modules = $modules = array(
      'inline_entity_form_test',
      'field',
      'field_ui',
    );
    parent::setUp($modules);
    $this->administrator_user = $this
      ->drupalCreateUser(array(
      'create ief_reference_type content',
      'edit any ief_reference_type content',
      'delete any ief_reference_type content',
      'create ief_test_multiple content',
      'edit any ief_test_multiple content',
      'delete any ief_test_multiple content',
      'edit any ief_test_nested1 content',
      'edit any ief_test_nested2 content',
      'edit any ief_test_nested3 content',
      'view own unpublished content',
      'administer content types',
      'administer nodes',
      'administer fields',
    ));
    $this
      ->drupalLogin($this->administrator_user);
    $this->formContentAddUrl = 'node/add/ief-test-multiple';
  }

  /**
   * Tests if form behaves correctly when field is empty.
   */
  public function testEmptyFieldIEF() {

    // Don't allow addition of existing nodes.
    $this
      ->setAllowExisting(FALSE);
    $this
      ->drupalGet($this->formContentAddUrl);
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][title]', NULL, 'Title field on inline form exists.');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][field_first_name][und][0][value]', NULL, 'First name field on inline form exists.');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][field_last_name][und][0][value]', NULL, 'Last name field on inline form exists.');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Create node"]', NULL, 'Found "Create node" submit button');

    // Allow addition of existing nodes.
    $this
      ->setAllowExisting(TRUE);
    $this
      ->drupalGet($this->formContentAddUrl);
    $this
      ->assertNoFieldByName('field_multiple_nodes[und][form][title]]', NULL, 'Title field does not appear.');
    $this
      ->assertNoFieldByName('field_multiple_nodes[und][form][field_first_name][und][0][value]', NULL, 'First name field does not appear.');
    $this
      ->assertNoFieldByName('field_multiple_nodes[und][form][field_last_name][und][0][value]', NULL, 'Last name field does not appear.');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Add new node"]', NULL, 'Found "Add new node" submit button');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Add existing node"]', NULL, 'Found "Add existing node" submit button');

    // Now submit 'Add new node' button.
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Add new node" and @id="edit-field-multiple-nodes-und-actions-ief-add"]'));
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][title]', NULL, 'Title field on inline form exists.');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][field_first_name][und][0][value]', NULL, 'First name field on inline form exists.');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][field_last_name][und][0][value]', NULL, 'Second name field on inline form exists.');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Create node"]', NULL, 'Found "Create node" submit button');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Cancel"]', NULL, 'Found "Cancel" submit button');

    // Now submit 'Add Existing node' button.
    $this
      ->drupalGet($this->formContentAddUrl);
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Add existing node" and @id="edit-field-multiple-nodes-und-actions-ief-add-existing"]'));
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][entity_id]', NULL, 'Existing entity reference autocomplete field found.');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Add node"]', NULL, 'Found "Add node" submit button');
    $this
      ->assertFieldByXpath('//input[@type="submit" and @value="Cancel"]', NULL, 'Found "Cancel" submit button');
  }

  /**
   * Tests creation of entities.
   */
  public function testEntityCreation() {

    // Allow addition of existing nodes.
    $this
      ->setAllowExisting(TRUE);
    $this
      ->drupalGet($this->formContentAddUrl);
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Add new node" and @id="edit-field-multiple-nodes-und-actions-ief-add"]'));
    $this
      ->assertResponse(200, 'Opening new inline form was successful.');
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Create node" and @id="edit-field-multiple-nodes-und-form-actions-ief-add-save"]'));
    $this
      ->assertResponse(200, 'Submitting empty form was successful.');
    $this
      ->assertText('First name field is required.', 'Validation failed for empty "First name" field.');
    $this
      ->assertText('Last name field is required.', 'Validation failed for empty "Last name" field.');
    $this
      ->assertText('Title field is required.', 'Validation failed for empty "Title" field.');

    // Create ief_reference_type node in IEF.
    $this
      ->drupalGet($this->formContentAddUrl);
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Add new node" and @id="edit-field-multiple-nodes-und-actions-ief-add"]'));
    $this
      ->assertResponse(200, 'Opening new inline form was successful.');
    $edit = array(
      'field_multiple_nodes[und][form][title]' => 'Some reference',
      'field_multiple_nodes[und][form][field_first_name][und][0][value]' => 'John',
      'field_multiple_nodes[und][form][field_last_name][und][0][value]' => 'Doe',
    );
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @value="Create node" and @id="edit-field-multiple-nodes-und-form-actions-ief-add-save"]'));
    $this
      ->assertResponse(200, 'Creating node via inline form was successful.');

    // Tests if correct fields appear in the table.
    $this
      ->assertTrue((bool) $this
      ->xpath('//td[@class="inline-entity-form-node-title" and contains(.,"Some reference")]'), 'Node title field appears in the table');
    $this
      ->assertTrue((bool) $this
      ->xpath('//td[@class="inline-entity-form-node-status" and contains(.,"Published")]'), 'Node status field appears in the table');

    // Tests if edit and remove buttons appear.
    $this
      ->assertTrue((bool) $this
      ->xpath('//input[@type="submit" and @value="Edit"]'), 'Edit button appears in the table.');
    $this
      ->assertTrue((bool) $this
      ->xpath('//input[@type="submit" and @value="Remove"]'), 'Remove button appears in the table.');

    // Test edit functionality.
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Edit"]'));
    $edit = array(
      'field_multiple_nodes[und][entities][0][form][title]' => 'Some changed reference',
    );
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @value="Update node"]'));
    $this
      ->assertTrue((bool) $this
      ->xpath('//td[@class="inline-entity-form-node-title" and contains(.,"Some changed reference")]'), 'Node title field appears in the table');
    $this
      ->assertTrue((bool) $this
      ->xpath('//td[@class="inline-entity-form-node-status" and contains(.,"Published")]'), 'Node status field appears in the table');

    // Make sure unrelated AJAX submit doesn't save the referenced entity.
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Upload"]'));
    $node = $this
      ->drupalGetNodeByTitle('Some changed reference');
    $this
      ->assertFalse($node, 'Referenced node was not saved during unrelated AJAX submit.');

    // Create ief_test_multiple node.
    $edit = array(
      'title' => 'Some title',
    );
    $this
      ->drupalPost(NULL, $edit, t('Save'));
    $this
      ->assertResponse(200, 'Saving parent entity was successful.');

    // Checks values of created entities.
    $node = $this
      ->drupalGetNodeByTitle('Some changed reference');
    $this
      ->assertTrue($node, 'Created ief_reference_type node ' . $node->title);
    $this
      ->assertTrue($node->field_first_name[LANGUAGE_NONE][0]['value'] == 'John', 'First name in reference node set to John');
    $this
      ->assertTrue($node->field_last_name[LANGUAGE_NONE][0]['value'] == 'Doe', 'Last name in reference node set to Doe');
    $parent_node = $this
      ->drupalGetNodeByTitle('Some title');
    $this
      ->assertTrue($parent_node, 'Created ief_test_multiple node ' . $parent_node->title);
    $this
      ->assertTrue($parent_node->field_multiple_nodes[LANGUAGE_NONE][0]['target_id'] == $node->nid, 'Refererence node id set to ' . $node->nid);
  }

  /**
   * Tests the entity creation with different bundles nested in each other.
   *
   * ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
   */
  public function testNestedEntityCreationWithDifferentBundlesAjaxSubmit() {
    $required_possibilities = array(
      FALSE,
      TRUE,
    );
    foreach ($required_possibilities as $required) {
      $this
        ->setupNestedMultipleForm($required);
      $nested3_title = 'nested3 title steps ' . ($required ? 'required' : 'not required');
      $nested2_title = 'nested2 title steps ' . ($required ? 'required' : 'not required');
      $nested1_title = 'nested1 title steps ' . ($required ? 'required' : 'not required');
      $edit = array(
        'field_test_ref_nested1[und][form][field_test_ref_nested2][und][form][title]' => $nested3_title,
      );
      $this
        ->drupalPostAjax(NULL, $edit, $this
        ->getButtonName('//input[@type="submit" and @value="Create node 3"]'));
      $this
        ->assertText($nested3_title, 'Title of second nested node found.');
      $this
        ->assertFalse($this
        ->drupalGetNodeByTitle($nested3_title), 'Second nested entity is not saved yet.');
      $edit = array(
        'field_test_ref_nested1[und][form][title]' => $nested2_title,
      );
      $this
        ->drupalPostAjax(NULL, $edit, $this
        ->getButtonName('//input[@type="submit" and @value="Create node 2"]'));
      $this
        ->assertText($nested2_title, 'Title of first nested node found.');
      $this
        ->assertFalse($this
        ->drupalGetNodeByTitle($nested2_title), 'First nested entity is not saved yet.');
      $edit = array(
        'title' => $nested1_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.");
      if ($this
        ->assertNotNull($nested1_node->field_test_ref_nested1[LANGUAGE_NONE][0]['target_id'], 'Second node was created.')) {
        $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.");
        if ($this
          ->assertNotNull($creatednested2->field_test_ref_nested2[LANGUAGE_NONE][0]['target_id'], 'Third node was created')) {
          $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, TRUE);
        }
      }
    }
  }

  /**
   * Tests the entity creation with different bundles nested in each other.
   *
   * ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
   */
  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);
    }
  }

  /**
   * Tests if editing and removing entities work.
   */
  public function testEntityEditingAndRemoving() {

    // Allow addition of existing nodes.
    $this
      ->setAllowExisting(TRUE);

    // Create three ief_reference_type entities.
    $referenceNodes = $this
      ->createReferenceContent(3);
    $field_multiple_nodes = array();
    foreach ($referenceNodes as $nid) {
      $field_multiple_nodes[LANGUAGE_NONE][] = array(
        'target_id' => $nid,
      );
    }
    $this
      ->drupalCreateNode(array(
      'type' => 'ief_test_multiple',
      'title' => 'Some title',
      'field_multiple_nodes' => $field_multiple_nodes,
    ));
    $parent_node = $this
      ->drupalGetNodeByTitle('Some title');

    // Edit the second entity.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    $cell = $this
      ->xpath('//table[@id="ief-entity-table-edit-field-multiple-nodes-und-entities"]/tbody/tr[@class="ief-row-entity draggable even"]/td[@class="inline-entity-form-node-title"]');
    $title = (string) $cell[0];
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @id="edit-field-multiple-nodes-und-entities-1-actions-ief-entity-edit"]'));
    $this
      ->assertResponse(200, 'Opening inline edit form was successful.');
    $edit = array(
      'field_multiple_nodes[und][entities][1][form][field_first_name][und][0][value]' => 'John',
      'field_multiple_nodes[und][entities][1][form][field_last_name][und][0][value]' => 'Doe',
    );
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @id="edit-field-multiple-nodes-und-entities-1-form-actions-ief-edit-save"]'));
    $this
      ->assertResponse(200, 'Saving inline edit form was successful.');

    // Save the ief_test_multiple node.
    $this
      ->drupalPost(NULL, array(), t('Save'));
    $this
      ->assertResponse(200, 'Saving parent entity was successful.');

    // Checks values of changed entities.
    $node = $this
      ->drupalGetNodeByTitle($title, TRUE);
    $this
      ->assertTrue($node->field_first_name[LANGUAGE_NONE][0]['value'] == 'John', 'First name in reference node changed to John');
    $this
      ->assertTrue($node->field_last_name[LANGUAGE_NONE][0]['value'] == 'Doe', 'Last name in reference node changed to Doe');

    // Delete the last entity.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    $cell = $this
      ->xpath('//table[@id="ief-entity-table-edit-field-multiple-nodes-und-entities"]/tbody//tr[3]//td[@class="inline-entity-form-node-title"]');
    $title = (string) $cell[0];
    $this
      ->drupalPost(NULL, array(), 'Remove');
    $this
      ->assertResponse(200, 'Opening inline remove confirm form was successful.');
    $this
      ->assertText('Are you sure you want to remove', 'Remove warning message is displayed.');
    $edit = array(
      'field_multiple_nodes[und][entities][2][form][delete]' => '1',
    );
    $this
      ->drupalPost(NULL, $edit, 'Remove');
    $this
      ->assertResponse(200, 'Removing inline entity was successful.');
    $this
      ->assertNoText($title, 'Deleted inline entity is not present on the page.');

    // Save the ief_test_multiple node.
    $this
      ->drupalPost(NULL, array(), t('Save'));
    $this
      ->assertResponse(200, 'Saving parent node was successful.');
    $deleted_node = $this
      ->drupalGetNodeByTitle($title);
    $this
      ->assertTrue(empty($deleted_node), 'The inline entity was deleted from the site.');

    // Checks that entity does nor appear in IEF.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    $this
      ->assertNoText($title, 'Deleted inline entity is not present on the page after saving parent.');

    // Delete the last entity reference only, don't delete the node. The last
    // entity now is second referenced entity because we already deleted one
    // in previous step.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    $cell = $this
      ->xpath('//table[@id="ief-entity-table-edit-field-multiple-nodes-und-entities"]/tbody//tr[2]//td[@class="inline-entity-form-node-title"]');
    $title = (string) $cell[0];
    $this
      ->drupalPost(NULL, array(), 'Remove');
    $this
      ->assertResponse(200, 'Opening inline remove confirm form was successful.');
    $this
      ->drupalPost(NULL, array(), 'Remove');
    $this
      ->assertResponse(200, 'Removing inline entity was successful.');

    // Save the ief_test_multiple node.
    $this
      ->drupalPost(NULL, array(), t('Save'));
    $this
      ->assertResponse(200, 'Saving parent node was successful.');

    // Checks that entity does nor appear in IEF.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    $this
      ->assertNoText($title, 'Deleted inline entity is not present on the page after saving parent.');

    // Checks that entity is not deleted.
    $node = $this
      ->drupalGetNodeByTitle($title, TRUE);
    $this
      ->assertTrue($node, 'Reference node not deleted');
  }

  /**
   * Tests if referencing existing entities work.
   */
  public function testReferencingExistingEntities() {

    // Allow addition of existing nodes.
    $this
      ->setAllowExisting(TRUE);

    // Create three ief_reference_type entities.
    $referenceNodes = $this
      ->createReferenceContent(3);

    // Create a node for every bundle available.
    $bundle_nodes = $this
      ->createNodeForEveryBundle();

    // Create ief_test_multiple node with first ief_reference_type node and first
    // node from bundle nodes.
    $this
      ->drupalCreateNode(array(
      'type' => 'ief_test_multiple',
      'title' => 'Some title',
      'multi' => array(
        1,
      ),
      'all_bundles' => key($bundle_nodes),
    ));

    // Remove first node since we already added it.
    unset($bundle_nodes[key($bundle_nodes)]);
    $parent_node = $this
      ->drupalGetNodeByTitle('Some title', TRUE);

    // Add remaining existing reference nodes.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    for ($i = 2; $i <= 3; $i++) {
      $this
        ->drupalPostAjax(NULL, array(), $this
        ->getButtonName('//input[@type="submit" and @value="Add existing node" and @id="edit-field-multiple-nodes-und-actions-ief-add-existing"]'));
      $this
        ->assertResponse(200, 'Opening reference form was successful.');
      $title = 'Some reference ' . $i;
      $edit = array(
        'field_multiple_nodes[und][form][entity_id]' => $title . ' (' . $referenceNodes[$title] . ')',
      );
      $this
        ->drupalPostAjax(NULL, $edit, $this
        ->getButtonName('//input[@type="submit" and @id="edit-field-multiple-nodes-und-form-actions-ief-reference-save"]'));
      $this
        ->assertResponse(200, 'Adding new referenced entity was successful.');
    }

    // Add all remaining nodes from all bundles.
    foreach ($bundle_nodes as $id => $title) {
      $this
        ->drupalPostAjax(NULL, array(), $this
        ->getButtonName('//input[@type="submit" and @value="Add existing node" and @id="edit-field-all-bundles-und-actions-ief-add-existing"]'));
      $this
        ->assertResponse(200, 'Opening reference form was successful.');
      $edit = array(
        'field_all_bundles[und][form][entity_id]' => $title . ' (' . $id . ')',
      );
      $this
        ->drupalPostAjax(NULL, $edit, $this
        ->getButtonName('//input[@type="submit" and @id="edit-field-all-bundles-und-form-actions-ief-reference-save"]'));
      $this
        ->assertResponse(200, 'Adding new referenced entity was successful.');
    }

    // Save the node.
    $this
      ->drupalPost(NULL, array(), t('Save'));
    $this
      ->assertResponse(200, 'Saving parent for was successful.');

    // Check if entities are referenced.
    $this
      ->drupalGet('node/' . $parent_node->nid . '/edit');
    for ($i = 2; $i <= 3; $i++) {
      $cell = $this
        ->xpath('//table[@id="ief-entity-table-edit-field-multiple-nodes-und-entities"]/tbody/tr[' . ($i - 1) . ']/td[@class="inline-entity-form-node-title"]');
      $this
        ->assertTrue($cell[0] == 'Some reference ' . $i, 'Found reference node title "Some reference ' . $i . '" in the IEF table.');
    }

    // Check if all remaining nodes from all bundles are referenced.
    $count = 1;
    foreach ($bundle_nodes as $id => $title) {
      $cell = $this
        ->xpath('//table[@id="ief-entity-table-edit-field-all-bundles-und-entities"]/tbody/tr[' . $count . ']/td[@class="inline-entity-form-node-title"]');
      $this
        ->assertTrue($cell[0] == $title, 'Found reference node title "' . $title . '" in the IEF table.');
      $count++;
    }
  }

  /**
   * Tests if a referenced content can be edited while the referenced content is
   * newer than the referencing parent node.
   */
  public function testEditedInlineEntityValidation() {
    $this
      ->setAllowExisting(TRUE);

    // Create referenced content.
    $referenced_nodes = $this
      ->createReferenceContent(1);
    $field_multiple_nodes = array();
    foreach ($referenced_nodes as $nid) {
      $field_multiple_nodes[LANGUAGE_NONE][] = array(
        'target_id' => $nid,
      );
    }

    // Create first referencing node.
    $this
      ->drupalCreateNode(array(
      'type' => 'ief_test_multiple',
      'title' => 'First referencing node',
      'field_multiple_nodes' => $field_multiple_nodes,
    ));
    $first_node = $this
      ->drupalGetNodeByTitle('First referencing node');

    // Create second referencing node.
    $this
      ->drupalCreateNode(array(
      'type' => 'ief_test_multiple',
      'title' => 'Second referencing node',
      'field_multiple_nodes' => $field_multiple_nodes,
    ));
    $second_node = $this
      ->drupalGetNodeByTitle('Second referencing node');

    // Edit referenced content in first node.
    $this
      ->drupalGet('node/' . $first_node->nid . '/edit');

    // Edit referenced node.
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Edit" and @id="edit-field-multiple-nodes-und-entities-0-actions-ief-entity-edit"]'));
    $edit = array(
      'field_multiple_nodes[und][entities][0][form][title]' => 'Some reference updated',
    );
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @value="Update node" and @id="edit-field-multiple-nodes-und-entities-0-form-actions-ief-edit-save"]'));

    // Save the first node after editing the reference.
    $edit = array(
      'title' => 'First node updated',
    );
    $this
      ->drupalPost(NULL, $edit, t('Save'));

    // The changed value of the referenced content is now newer than the
    // changed value of the second node.
    // Edit referenced content in second node.
    $this
      ->drupalGet('node/' . $second_node->nid . '/edit');

    // Edit referenced node.
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Edit" and @id="edit-field-multiple-nodes-und-entities-0-actions-ief-entity-edit"]'));
    $edit = array(
      'field_multiple_nodes[und][entities][0][form][title]' => 'Some reference updated the second time',
    );
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @value="Update node" and @id="edit-field-multiple-nodes-und-entities-0-form-actions-ief-edit-save"]'));

    // Save the second node after editing the reference.
    $edit = array(
      'title' => 'Second node updated',
    );
    $this
      ->drupalPost(NULL, $edit, t('Save'));

    // Check if the referenced content could be edited.
    $this
      ->assertNoText('The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.', 'The referenced content could be edited.');
  }

  /**
   * Tests create access on IEF Multiple content type.
   */
  public function testMultipleEntityCreate() {
    $user = $this
      ->drupalCreateUser(array(
      'create ief_test_multiple content',
    ));
    $this
      ->drupalLogin($user);
    $this
      ->drupalGet('node/add/ief-test-multiple');
    $this
      ->assertNoFieldByName('field_all_bundles[und][actions][bundle]', NULL, 'Bundle select is not shown when only one bundle is available.');
    $this
      ->assertNoFieldByName('field_multiple_nodes[und][form][title]', NULL);
    $user = $this
      ->drupalCreateUser(array(
      'create ief_test_multiple content',
      'create ief_reference_type content',
    ));
    $this
      ->drupalLogin($user);
    $this
      ->drupalGet('node/add/ief-test-multiple');
    $this
      ->assertFieldByName('field_all_bundles[und][actions][bundle]', NULL, 'Bundle select is shown when more than one bundle is available.');
    $this
      ->assertTrue((bool) $this
      ->xpath('//select[@id="edit-field-all-bundles-und-actions-bundle"]//option[@value="ief_reference_type"]'), 'IEF Reference type is available');
    $this
      ->assertTrue((bool) $this
      ->xpath('//select[@id="edit-field-all-bundles-und-actions-bundle"]//option[@value="ief_test_multiple"]'), 'IEF test multiple is available');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][title]');
  }

  /**
   * Tests entity create access is correct on nested IEF forms.
   */
  public function testNestedEntityCreateAccess() {
    $permissions = array(
      'create ief_test_nested1 content',
      'create ief_test_nested2 content',
    );
    $this
      ->setupNestedMultipleForm(TRUE, $permissions);
    $this
      ->assertFieldByName('title');
    $this
      ->assertFieldByName('field_test_ref_nested1[und][form][title]');
    $this
      ->assertNoFieldByName('field_test_ref_nested1[und][form][field_test_ref_nested2][und][form][title]', NULL);
    $this
      ->setupNestedMultipleForm(FALSE, $permissions);
    $this
      ->assertNoFieldByXPath('//input[@type="submit" and @value="Create node 3"]');
  }

  /**
   * Creates ief_reference_type nodes which shall serve as reference nodes.
   *
   * @param int $numNodes
   *   The number of nodes to create
   * @return array
   *   Array of created node ids keyed by labels.
   */
  protected function createReferenceContent($numNodes = 3) {
    $retval = array();
    for ($i = 1; $i <= $numNodes; $i++) {
      $this
        ->drupalCreateNode(array(
        'type' => 'ief_reference_type',
        'title' => 'Some reference ' . $i,
        'field_first_name' => 'First Name ' . $i,
        'field_last_name' => 'Last Name ' . $i,
      ));
      $node = $this
        ->drupalGetNodeByTitle('Some reference ' . $i);
      $this
        ->assertTrue($node, 'Created ief_reference_type node "' . $node->title . '"');
      $retval[$node->title] = $node->nid;
    }
    return $retval;
  }

  /**
   * Sets allow_existing IEF setting.
   *
   * @param bool $flag
   *   "allow_existing" flag to be set.
   */
  protected function setAllowExisting($flag) {
    $edit = array(
      'instance[widget][settings][type_settings][allow_existing]' => $flag,
    );
    $this
      ->drupalPost('admin/structure/types/manage/ief-test-multiple/fields/field_multiple_nodes', $edit, t('Save settings'));
    $this
      ->drupalGet('admin/structure/types/manage/ief-test-multiple/fields/field_multiple_nodes');
  }

  /**
   * Creates a node for every node bundle.
   *
   * @return array
   *   Array of node titles keyed by ids.
   */
  protected function createNodeForEveryBundle() {
    $retval = array();
    $bundles = node_type_get_types();
    foreach ($bundles as $id => $value) {
      $this
        ->drupalCreateNode(array(
        'type' => $id,
        'title' => $value->name,
      ));
      $node = $this
        ->drupalGetNodeByTitle($value->name);
      $this
        ->assertTrue($node, 'Created node "' . $node->title . '"');
      $retval[$node->nid] = $value->name;
    }
    return $retval;
  }

  /**
   * Set up the ief_test_nested1 node add form.
   *
   * Sets the nested fields' required settings.
   * Gets the form.
   * Opens the inline entity forms if they are not required.
   *
   * @param boolean $required
   *   Whether the fields are required.
   * @param array $permissions
   *   (optional) Permissions to sign testing user in with. You may pass in an
   *   empty array (default) to use the all the permissions necessary create and
   *   edit nodes on the form.
   */
  protected function setupNestedMultipleForm($required, $permissions = array()) {
    $this
      ->drupalLogin($this->administrator_user);
    $edit = array(
      'instance[required]' => $required,
    );
    $this
      ->drupalPost('admin/structure/types/manage/ief-test-nested1/fields/field_test_ref_nested1', $edit, t('Save settings'));
    $this
      ->drupalPost('admin/structure/types/manage/ief-test-nested2/fields/field_test_ref_nested2', $edit, t('Save settings'));
    if (!$permissions) {
      $permissions = array(
        'create ief_test_nested1 content',
        'create ief_test_nested2 content',
        'create ief_test_nested3 content',
        'edit any ief_test_nested1 content',
        'edit any ief_test_nested2 content',
        'edit any ief_test_nested3 content',
      );
    }
    $this->user = $this
      ->drupalCreateUser($permissions);
    $this
      ->drupalLogin($this->user);
    $this
      ->drupalGet('node/add/ief-test-nested1');
    if (!$required) {

      // Open inline forms if not required.
      if (in_array('create ief_test_nested2 content', $permissions)) {
        $this
          ->drupalPostAjax(NULL, array(), $this
          ->getButtonName('//input[@type="submit" and @value="Add new node 2"]'));
      }
      if (in_array('create ief_test_nested3 content', $permissions)) {
        $this
          ->drupalPostAjax(NULL, array(), $this
          ->getButtonName('//input[@type="submit" and @value="Add new node 3"]'));
      }
    }
  }

  /**
   * Closes the existing node form on the "multi" field.
   */
  protected function cancelExistingMultiForm($edit) {
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//div[@id="edit-field-multiple-nodes"]//input[@type="submit" and @value="Cancel"]'));
    $this
      ->assertNoFieldByName('field_multiple_nodes[und][form][entity_id]', NULL, 'Existing entity reference autocomplete field removed.');
  }

  /**
   * Opens the existing node form on the "multi" field.
   */
  protected function openMultiExistingForm() {
    $this
      ->drupalPostAjax(NULL, array(), $this
      ->getButtonName('//input[@type="submit" and @value="Add existing node" and @id="edit-field-multiple-nodes-und-actions-ief-add-existing"]'));
    $this
      ->assertResponse(200, 'Opening reference form was successful.');
    $this
      ->assertFieldByName('field_multiple_nodes[und][form][entity_id]', NULL, 'Existing entity reference autocomplete field found.');
  }

  /**
   * Checks that nested IEF entity references can be edit and saved.
   *
   * @param $node
   *  Top level node of type ief_test_nested1 to check.
   * @param bool $ajax_submit
   *  Whether IEF form widgets should be submitted via AJax or left open.
   *
   */
  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);
  }

  /**
   * Checks that an invalid value for an existing node will be display the expected error.
   *
   * @param $existing_node_text
   *  The text to enter into the existing node text field.
   * @param $expected_error
   *  The error message that is expected to be shown.
   */
  protected function checkExistingValidationExpectation($existing_node_text, $expected_error) {
    $edit = array(
      'field_multiple_nodes[und][form][entity_id]' => $existing_node_text,
    );
    $this
      ->openMultiExistingForm();
    $this
      ->drupalPostAjax(NULL, $edit, $this
      ->getButtonName('//input[@type="submit" and @id="edit-field-multiple-nodes-und-form-actions-ief-reference-save"]'));
    $this
      ->assertText($expected_error);
    $this
      ->cancelExistingMultiForm($edit);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$profile protected property The profile to install as a basis for testing. 20
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. 6
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1
InlineEntityFormTestBase::$user protected property
InlineEntityFormTestBase::assertNodeByTitle protected function Passes if node is found for the title.
InlineEntityFormTestBase::assertNoNodeByTitle protected function Passes if no node is found for the title.
InlineEntityFormTestBase::getButtonName protected function Gets IEF button name.
MultipleValuesWidgetTest::$formContentAddUrl protected property URL to add new content.
MultipleValuesWidgetTest::cancelExistingMultiForm protected function Closes the existing node form on the "multi" field.
MultipleValuesWidgetTest::checkExistingValidationExpectation protected function Checks that an invalid value for an existing node will be display the expected error.
MultipleValuesWidgetTest::checkNestedEntityEditing protected function Checks that nested IEF entity references can be edit and saved.
MultipleValuesWidgetTest::createNodeForEveryBundle protected function Creates a node for every node bundle.
MultipleValuesWidgetTest::createReferenceContent protected function Creates ief_reference_type nodes which shall serve as reference nodes.
MultipleValuesWidgetTest::getInfo public static function
MultipleValuesWidgetTest::openMultiExistingForm protected function Opens the existing node form on the "multi" field.
MultipleValuesWidgetTest::setAllowExisting protected function Sets allow_existing IEF setting.
MultipleValuesWidgetTest::setUp protected function Sets up a Drupal site for running functional and integration tests. Overrides DrupalWebTestCase::setUp
MultipleValuesWidgetTest::setupNestedMultipleForm protected function Set up the ief_test_nested1 node add form.
MultipleValuesWidgetTest::testEditedInlineEntityValidation public function Tests if a referenced content can be edited while the referenced content is newer than the referencing parent node.
MultipleValuesWidgetTest::testEmptyFieldIEF public function Tests if form behaves correctly when field is empty.
MultipleValuesWidgetTest::testEntityCreation public function Tests creation of entities.
MultipleValuesWidgetTest::testEntityEditingAndRemoving public function Tests if editing and removing entities work.
MultipleValuesWidgetTest::testMultipleEntityCreate public function Tests create access on IEF Multiple content type.
MultipleValuesWidgetTest::testNestedEntityCreateAccess public function Tests entity create access is correct on nested IEF forms.
MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesAjaxSubmit public function Tests the entity creation with different bundles nested in each other.
MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit public function Tests the entity creation with different bundles nested in each other.
MultipleValuesWidgetTest::testReferencingExistingEntities public function Tests if referencing existing entities work.