function InlineBlockPrivateFilesTest::attachFileToBlockForm

Same name in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::attachFileToBlockForm()
  2. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::attachFileToBlockForm()
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::attachFileToBlockForm()

Attaches a file to the block edit form.

Parameters

\Drupal\file\FileInterface $file: The file to be attached.

2 calls to InlineBlockPrivateFilesTest::attachFileToBlockForm()
InlineBlockPrivateFilesTest::addInlineFileBlockToLayout in core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
Adds an entity block with a file.
InlineBlockPrivateFilesTest::replaceFileInBlock in core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
Replaces the file in the block with another one.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php, line 269

Class

InlineBlockPrivateFilesTest
Test access to private files in block fields on the Layout Builder.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function attachFileToBlockForm(FileInterface $file) {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->assertSession()
        ->waitForElementVisible('named', [
        'field',
        'files[settings_block_form_field_file_0]',
    ]);
    $page->attachFileToField("files[settings_block_form_field_file_0]", $this->fileSystem
        ->realpath($file->getFileUri()));
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertNotEmpty($assert_session->waitForLink($file->label()));
}

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