protected function ImageItemTest::setUp in Drupal 10        
                          
                  
                        Same name and namespace in other branches
- 8 core/modules/image/tests/src/Kernel/ImageItemTest.php \Drupal\Tests\image\Kernel\ImageItemTest::setUp()
- 9 core/modules/image/tests/src/Kernel/ImageItemTest.php \Drupal\Tests\image\Kernel\ImageItemTest::setUp()
File
 
   - core/modules/image/tests/src/Kernel/ImageItemTest.php, line 43
Class
  
  - ImageItemTest 
- Tests using entity fields of the image field type.
Namespace
  Drupal\Tests\image\Kernel
Code
protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('user');
  $this
    ->installConfig([
    'user',
  ]);
  
  $anonymous_role = Role::load(Role::ANONYMOUS_ID);
  $anonymous_role
    ->grantPermission('access content');
  $anonymous_role
    ->save();
  $this
    ->installEntitySchema('file');
  $this
    ->installSchema('file', [
    'file_usage',
  ]);
  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',
    'settings' => [
      'file_extensions' => 'jpg',
    ],
  ])
    ->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');
}