class FileFieldFormatterAccessTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/file/tests/src/Functional/FileFieldFormatterAccessTest.php \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest
- 9 core/modules/file/tests/src/Functional/FileFieldFormatterAccessTest.php \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest
Tests file formatter access. @group file
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\file\Functional\FileFieldTestBase uses FileFieldCreationTrait, TestFileCreationTrait
- class \Drupal\Tests\file\Functional\FileFieldFormatterAccessTest
- class \Drupal\Tests\file\Functional\FileFieldTestBase uses FileFieldCreationTrait, TestFileCreationTrait
Expanded class hierarchy of FileFieldFormatterAccessTest
File
- core/
modules/ file/ tests/ src/ Functional/ FileFieldFormatterAccessTest.php, line 9
Namespace
Drupal\Tests\file\FunctionalView source
class FileFieldFormatterAccessTest extends FileFieldTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
'file',
'field_ui',
'file_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the custom access handler is invoked.
*/
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));
}
}