function FileFieldFormatterAccessTest::testFileAccessHandler
Same name in other branches
- 8.9.x core/modules/file/tests/src/Functional/FileFieldFormatterAccessTest.php \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest::testFileAccessHandler()
- 10 core/modules/file/tests/src/Functional/FileFieldFormatterAccessTest.php \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest::testFileAccessHandler()
- 11.x core/modules/file/tests/src/Functional/FileFieldFormatterAccessTest.php \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest::testFileAccessHandler()
Tests the custom access handler is invoked.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileFieldFormatterAccessTest.php, line 26
Class
- FileFieldFormatterAccessTest
- Tests file formatter access. @group file
Namespace
Drupal\Tests\file\FunctionalCode
public function testFileAccessHandler() {
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name);
\Drupal::state()->set('file_test_alternate_access_handler', TRUE);
\Drupal::entityTypeManager()->clearCachedDefinitions();
$test_file = $this->getTestFile('text');
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$this->drupalGet('node/' . $nid);
$this->assertTrue(\Drupal::state()->get('file_access_formatter_check', FALSE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.