3 namespace Drupal\file\Tests;
6 * Tests file formatter access.
9 class FileFieldFormatterAccessTest extends FileFieldTestBase {
16 public static $modules = ['node', 'file', 'field_ui', 'file_test'];
19 * Tests the custom access handler is invoked.
21 public function testFileAccessHandler() {
22 $type_name = 'article';
23 $field_name = strtolower($this->randomMachineName());
24 $this->createFileField($field_name, 'node', $type_name);
25 \Drupal::state()->set('file_test_alternate_access_handler', TRUE);
26 \Drupal::entityManager()->clearCachedDefinitions();
27 $test_file = $this->getTestFile('text');
28 $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
29 $this->drupalGet('node/' . $nid);
30 $this->assertTrue(\Drupal::state()->get('file_access_formatter_check', FALSE));