You are here

protected function ImageStyleTest::createEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/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

core/modules/jsonapi/tests/src/Functional/ImageStyleTest.php, line 59

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;
}