You are here

protected function ComplexWidgetTest::setupNestedComplexForm in Inline Entity Form 8

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.

Parameters

bool $required: Whether the fields are required.

4 calls to ComplexWidgetTest::setupNestedComplexForm()
ComplexWidgetTest::testNestedCreateAndEditWontClash in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests that create and edit of nested data won#t clash.
ComplexWidgetTest::testNestedEntityCreationWithDifferentBundlesAjaxSubmit in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests the entity creation with different bundles nested in each other.
ComplexWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests the entity creation with different bundles nested in each other.
ComplexWidgetTest::testSeparateNestedDataMultiValueFields in tests/src/FunctionalJavascript/ComplexWidgetTest.php
Tests the separation of nested data.

File

tests/src/FunctionalJavascript/ComplexWidgetTest.php, line 778

Class

ComplexWidgetTest
IEF complex field widget tests.

Namespace

Drupal\Tests\inline_entity_form\FunctionalJavascript

Code

protected function setupNestedComplexForm(bool $required) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();

  /** @var \Drupal\Core\Field\FieldConfigInterface $ief_test_nested1 */
  $this->fieldConfigStorage
    ->load('node.ief_test_nested1.test_ref_nested1')
    ->setRequired($required)
    ->save();

  /** @var \Drupal\Core\Field\FieldConfigInterface $ief_test_nested2 */
  $this->fieldConfigStorage
    ->load('node.ief_test_nested2.test_ref_nested2')
    ->setRequired($required)
    ->save();
  $this
    ->drupalGet('node/add/ief_test_nested1');
  if (!$required) {

    // Open inline forms if not required.
    $page
      ->pressButton('Add new node 2');
    $this
      ->assertNotEmpty($button = $assert_session
      ->waitForButton('Add new node 3'));
    $button
      ->press();
    $this
      ->assertNotEmpty($assert_session
      ->waitForButton('Create node 3'));
  }
}