public function FileUrlFieldItemListTest::setUp in File URL 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/FileUrlFieldItemListTest.php \Drupal\Tests\file_url\Kernel\FileUrlFieldItemListTest::setUp()
Set the default field storage backend for fields created during tests.
Overrides FieldKernelTestBase::setUp
File
- tests/
src/ Kernel/ FileUrlFieldItemListTest.php, line 59
Class
- FileUrlFieldItemListTest
- Tests the overridden field item list.
Namespace
Drupal\Tests\file_url\KernelCode
public function setUp() {
parent::setUp();
$this->entityTypeManager = $this->container
->get('entity_type.manager');
$this
->installEntitySchema('file');
$this
->installSchema('file', [
'file_usage',
]);
FieldStorageConfig::create([
'field_name' => 'file_url_test',
'entity_type' => 'entity_test',
'type' => 'file_url',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
])
->save();
$this->directory = $this
->getRandomGenerator()
->name(8);
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'file_url_test',
'bundle' => 'entity_test',
'settings' => [
'file_directory' => $this->directory,
],
])
->save();
// Create a local test file.
file_put_contents('public://example.txt', $this
->randomMachineName());
$this->localFile = File::create([
'uri' => 'public://example.txt',
]);
$this->localFile
->save();
// Create a remote test file.
$this->remoteFile = RemoteFile::create([
'uri' => $this
->getRandomUrl(),
]);
$this->remoteFile
->save();
}