public function ImageItemTest::setUp

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

Overrides FieldUnitTestBase::setUp

File

drupal/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php, line 41
Contains \Drupal\image\Tests\ImageItemTest.

Class

ImageItemTest
Tests the new entity API for the image field type.

Namespace

Drupal\image\Tests

Code

public function setUp() {
  parent::setUp();
  $this
    ->installSchema('file', array(
    'file_managed',
    'file_usage',
  ));
  $field = array(
    'field_name' => 'image_test',
    'type' => 'image',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  );
  field_create_field($field);
  $instance = array(
    'entity_type' => 'entity_test',
    'field_name' => 'image_test',
    'bundle' => 'entity_test',
  );
  field_create_instance($instance);
  file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
  $this->image = entity_create('file', array(
    'uri' => 'public://example.jpg',
  ));
  $this->image
    ->save();
}