View source
<?php
namespace Drupal\Tests\image\Functional\Rest;
use Drupal\image\Entity\ImageStyle;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
abstract class ImageStyleResourceTestBase extends EntityResourceTestBase {
protected static $modules = [
'image',
];
protected static $entityTypeId = 'image_style';
protected $entity;
protected $effectUuid;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer image styles',
]);
}
protected function createEntity() {
$camelids = ImageStyle::create([
'name' => 'camelids',
'label' => 'Camelids',
]);
$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;
}
protected function getExpectedNormalizedEntity() {
return [
'dependencies' => [],
'effects' => [
$this->effectUuid => [
'uuid' => $this->effectUuid,
'id' => 'image_scale_and_crop',
'weight' => 0,
'data' => [
'anchor' => 'center-center',
'width' => 120,
'height' => 121,
],
],
],
'label' => 'Camelids',
'langcode' => 'en',
'name' => 'camelids',
'status' => TRUE,
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
}
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The 'administer image styles' permission is required.";
}
}