You are here

protected function ImageStyleTest::createEntity in JSON:API 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/ImageStyleTest.php \Drupal\Tests\jsonapi\Functional\ImageStyleTest::createEntity()

Creates the entity to be tested.

Return value

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

Overrides ResourceTestBase::createEntity

File

tests/src/Functional/ImageStyleTest.php, line 54

Class

ImageStyleTest
JSON:API integration test for the "ImageStyle" config entity type.

Namespace

Drupal\Tests\jsonapi\Functional

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' => [
      'width' => 120,
      'height' => 121,
    ],
    'weight' => 0,
  ];
  $this->effectUuid = $camelids
    ->addImageEffect($effect);
  $camelids
    ->save();
  return $camelids;
}