Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / src / Tests / FileFieldFormatterAccessTest.php
1 <?php
2
3 namespace Drupal\file\Tests;
4
5 /**
6  * Tests file formatter access.
7  * @group file
8  */
9 class FileFieldFormatterAccessTest extends FileFieldTestBase {
10
11   /**
12    * Modules to enable.
13    *
14    * @var array
15    */
16   public static $modules = ['node', 'file', 'field_ui', 'file_test'];
17
18   /**
19    * Tests the custom access handler is invoked.
20    */
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));
31   }
32
33 }