function QuickEditFileTest::setUp

Same name in other branches
  1. 8.9.x core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditFileTest.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditFileTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditFileTest.php, line 36

Class

QuickEditFileTest
@group quickedit @group legacy

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    // Create the Article node type.
    $this->drupalCreateContentType([
        'type' => 'article',
        'name' => 'Article',
    ]);
    // Add file field to Article node type.
    $this->createFileField('field_file', 'node', 'article', [
        'file_extensions' => 'txt',
    ]);
    // Move file field to the top of all fields, so its QuickEdit Toolbar won't
    // overlap any QuickEdit-able fields, which causes (semi-)random test
    // failures.
    $entity_display = EntityViewDisplay::load('node.article.default');
    $entity_display->setComponent('field_file', [
        'weight' => 0,
    ]);
    $entity_display->save();
    // Log in as a content author who can use Quick Edit and edit Articles.
    $user = $this->drupalCreateUser([
        'access contextual links',
        'access toolbar',
        'access in-place editing',
        'access content',
        'create article content',
        'edit any article content',
    ]);
    $this->drupalLogin($user);
}

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