You are here

protected function ImageStyleResourceTestBase::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityResourceTestBase::createEntity

File

core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php, line 47

Class

ImageStyleResourceTestBase
ResourceTestBase for ImageStyle entity.

Namespace

Drupal\Tests\image\Functional\Rest

Code

protected function createEntity() {

  // Create a "Camelids" image style.
  $camelids = ImageStyle::create([
    'name' => 'camelids',
    'label' => 'Camelids',
  ]);

  // Add an image effect.
  $effect = [
    'id' => 'image_scale_and_crop',
    'data' => [
      'anchor' => 'center-center',
      'width' => 120,
      'height' => 121,
    ],
    'weight' => 0,
  ];
  $this->effectUuid = $camelids
    ->addImageEffect($effect);
  $camelids
    ->save();
  return $camelids;
}