protected function ComplexWidgetTest::checkNestedNodeEditing in Inline Entity Form 8
Checks that nested IEF entity references can be edited and saved.
Parameters
\Drupal\node\NodeInterface $node: Top level node of type ief_test_nested1 to check.
1 call to ComplexWidgetTest::checkNestedNodeEditing()
- ComplexWidgetTest::checkNestedNodes in tests/
src/ FunctionalJavascript/ ComplexWidgetTest.php - Checks if nested nodes for ief_test_nested1 content are created.
File
- tests/
src/ FunctionalJavascript/ ComplexWidgetTest.php, line 670
Class
- ComplexWidgetTest
- IEF complex field widget tests.
Namespace
Drupal\Tests\inline_entity_form\FunctionalJavascriptCode
protected function checkNestedNodeEditing(NodeInterface $node) {
// Get the xpath selectors for the input fields in this test.
$double_nested_title_field_xpath = $this
->getXpathForNthInputByLabelText('Title', 3);
$title_field_xpath = $this
->getXpathForNthInputByLabelText('Title', 1);
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$nested_node = $node->test_ref_nested1->entity;
$double_nested_node = $nested_node->test_ref_nested2->entity;
$this
->drupalGet("node/{$node->id()}/edit");
$this
->assertRowByTitle($nested_node
->label());
$page
->pressButton('Edit');
$this
->waitForRowByTitle($double_nested_node
->label());
$page
->pressButton('Edit');
$this
->assertNotEmpty($assert_session
->waitforButton('Update node 3'));
$double_nested_node_update_title = $double_nested_node
->getTitle() . ' - updated';
$assert_session
->elementExists('xpath', $double_nested_title_field_xpath)
->setValue($double_nested_node_update_title);
// Close the double nested IEF form.
$page
->pressButton('Update node 3');
$this
->waitForRowByTitle($double_nested_node_update_title);
// Close the nested IEF form.
$page
->pressButton('Update node 2');
$this
->assertNotEmpty($assert_session
->waitForElementRemoved('css', 'div[data-drupal-selector="edit-test-ref-nested1-form-inline-entity-form-entities-0-form"]'));
$this
->waitForRowByTitle($nested_node
->label());
// Save the top level node.
$page
->pressButton('Save');
$assert_session
->pageTextContains('IEF test nested 1 ' . $node
->label() . ' has been updated.');
// Verify the double nested node title change saved properly.
$this
->drupalGet("node/{$node->id()}/edit");
$page
->pressButton('Edit');
$this
->waitForRowByTitle($double_nested_node_update_title);
$this
->drupalGet("node/{$double_nested_node->id()}/edit");
$this
->assertSame($double_nested_node_update_title, $assert_session
->elementExists('xpath', $title_field_xpath)
->getValue());
}