protected function FileItemTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Tests/FileItemTest.php \Drupal\file\Tests\FileItemTest::setUp()
Set the default field storage backend for fields created during tests.
Overrides FieldUnitTestBase::setUp
File
- core/
modules/ file/ src/ Tests/ FileItemTest.php, line 44 - Contains \Drupal\file\Tests\FileItemTest.
Class
- FileItemTest
- Tests using entity fields of the file field type.
Namespace
Drupal\file\TestsCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('file');
$this
->installSchema('file', array(
'file_usage',
));
entity_create('field_storage_config', array(
'field_name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))
->save();
$this->directory = $this
->getRandomGenerator()
->name(8);
entity_create('field_config', array(
'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',
'settings' => array(
'file_directory' => $this->directory,
),
))
->save();
file_put_contents('public://example.txt', $this
->randomMachineName());
$this->file = entity_create('file', array(
'uri' => 'public://example.txt',
));
$this->file
->save();
}