public function MultipleValuesWidgetTest::testEditedInlineEntityValidation in Inline Entity Form 7
Tests if a referenced content can be edited while the referenced content is newer than the referencing parent node.
File
- tests/
multiple_values_widget.test, line 418
Class
- MultipleValuesWidgetTest
- IEF multiple values field widget tests.
Code
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.');
}