You are here

protected function InlineBlockPrivateFilesTest::assertFileAccessibleOnNode in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::assertFileAccessibleOnNode()

Asserts a file is accessible on the page.

Parameters

\Drupal\file\FileInterface $file: The file entity.

Return value

string The file href.

1 call to InlineBlockPrivateFilesTest::assertFileAccessibleOnNode()
InlineBlockPrivateFilesTest::testPrivateFiles in core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
Tests access to private files added to inline blocks in the layout builder.

File

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

Class

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

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function assertFileAccessibleOnNode(FileInterface $file) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session
    ->linkExists($file
    ->label());
  $private_href = $page
    ->findLink($file
    ->label())
    ->getAttribute('href');
  $page
    ->clickLink($file
    ->label());
  $assert_session
    ->pageTextContains($this
    ->getFileSecret($file));

  // Access file directly.
  $this
    ->drupalGet($private_href);
  $assert_session
    ->pageTextContains($this
    ->getFileSecret($file));
  return $private_href;
}