function ImageStyleResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase::createEntity()
  2. 10 core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase::createEntity()
  3. 11.x core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase::createEntity()

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

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