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