$anonymous_role->
save();
$this->
installEntitySchema('file'
);
$this->
installSchema('file',
['file_usage'
]);
FieldStorageConfig::
create([ 'field_name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
])->
save();
$this->directory =
$this->
getRandomGenerator()->
name(8
);
FieldConfig::
create([ 'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',
'settings' =>
['file_directory' =>
$this->directory
],
])->
save();
file_put_contents('public://example.txt',
$this->
randomMachineName());
$this->file = File::
create([ 'uri' => 'public://example.txt',
]);
$this->file->
save();
}