function InlineBlockPrivateFilesTest::getFileHrefAccessibleOnNode

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::getFileHrefAccessibleOnNode()
  2. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest::getFileHrefAccessibleOnNode()

Returns the href of a file, asserting it is accessible on the page.

Parameters

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

Return value

string The file href.

1 call to InlineBlockPrivateFilesTest::getFileHrefAccessibleOnNode()
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 239

Class

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

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function getFileHrefAccessibleOnNode(FileInterface $file) : string {
  $page = $this->getSession()
    ->getPage();
  $this->assertSession()
    ->linkExists($file->label());
  $private_href = $page->findLink($file->label())
    ->getAttribute('href');
  $page->clickLink($file->label());
  $this->assertSession()
    ->pageTextContains($this->getFileSecret($file));
  // Access file directly.
  $this->drupalGet($private_href);
  $this->assertSession()
    ->pageTextContains($this->getFileSecret($file));
  return $private_href;
}

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