public function FileItemTest::setUp

Set the default field storage backend for fields created during tests.

Overrides FieldUnitTestBase::setUp

File

drupal/core/modules/file/lib/Drupal/file/Tests/FileItemTest.php, line 41
Contains \Drupal\file\Tests\FileItemTest.

Class

FileItemTest
Tests the new entity API for the file field type.

Namespace

Drupal\file\Tests

Code

public function setUp() {
  parent::setUp();
  $this
    ->installSchema('file', 'file_managed');
  $this
    ->installSchema('file', 'file_usage');
  $field = array(
    'field_name' => 'file_test',
    'type' => 'file',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  );
  field_create_field($field);
  $instance = array(
    'entity_type' => 'entity_test',
    'field_name' => 'file_test',
    'bundle' => 'entity_test',
  );
  field_create_instance($instance);
  file_put_contents('public://example.txt', $this
    ->randomName());
  $this->file = entity_create('file', array(
    'uri' => 'public://example.txt',
  ));
  $this->file
    ->save();
}