function MultiFormTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php \Drupal\FunctionalJavascriptTests\Ajax\MultiFormTest::setUp()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php \Drupal\FunctionalJavascriptTests\Ajax\MultiFormTest::setUp()
  3. 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php \Drupal\FunctionalJavascriptTests\Ajax\MultiFormTest::setUp()

Overrides BrowserTestBase::setUp

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php, line 32

Class

MultiFormTest
Tests AJAX-enabled forms when multiple instances of the form are on a page.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

protected function setUp() : void {
    parent::setUp();
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Page',
    ]);
    // Create a multi-valued field for 'page' nodes to use for Ajax testing.
    $field_name = 'field_ajax_test';
    FieldStorageConfig::create([
        'entity_type' => 'node',
        'field_name' => $field_name,
        'type' => 'text',
        'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ])->save();
    FieldConfig::create([
        'field_name' => $field_name,
        'entity_type' => 'node',
        'bundle' => 'page',
    ])->save();
    \Drupal::service('entity_display.repository')->getFormDisplay('node', 'page', 'default')
        ->setComponent($field_name, [
        'type' => 'text_textfield',
    ])
        ->save();
    // Log in a user who can create 'page' nodes.
    $this->drupalLogin($this->drupalCreateUser([
        'create page content',
    ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.