function ImageThemeFunctionTest::setUp

Same name in other branches
  1. 9 core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php \Drupal\Tests\image\Kernel\ImageThemeFunctionTest::setUp()
  2. 10 core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php \Drupal\Tests\image\Kernel\ImageThemeFunctionTest::setUp()
  3. 11.x core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php \Drupal\Tests\image\Kernel\ImageThemeFunctionTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php, line 54

Class

ImageThemeFunctionTest
Tests image theme functions.

Namespace

Drupal\Tests\image\Kernel

Code

protected function setUp() {
    parent::setUp();
    $this->installEntitySchema('entity_test');
    $this->installEntitySchema('file');
    $this->installSchema('file', [
        'file_usage',
    ]);
    $this->installEntitySchema('user');
    FieldStorageConfig::create([
        'entity_type' => 'entity_test',
        'field_name' => 'image_test',
        'type' => 'image',
        'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ])->save();
    FieldConfig::create([
        'entity_type' => 'entity_test',
        'field_name' => 'image_test',
        'bundle' => 'entity_test',
    ])->save();
    \Drupal::service('file_system')->copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
    $this->image = File::create([
        'uri' => 'public://example.jpg',
    ]);
    $this->image
        ->save();
    $this->imageFactory = $this->container
        ->get('image.factory');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.