3 namespace Drupal\Tests\rest\Functional\EntityResource\ImageStyle;
5 use Drupal\image\Entity\ImageStyle;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
9 * ResourceTestBase for ImageStyle entity.
11 abstract class ImageStyleResourceTestBase extends EntityResourceTestBase {
16 public static $modules = ['image'];
21 protected static $entityTypeId = 'image_style';
24 * The ImageStyle entity.
26 * @var \Drupal\image\ImageStyleInterface
35 protected $effectUuid;
40 protected function setUpAuthorization($method) {
41 $this->grantPermissionsToTestedRole(['administer image styles']);
47 protected function createEntity() {
48 // Create a "Camelids" image style.
49 $camelids = ImageStyle::create([
51 'label' => 'Camelids',
54 // Add an image effect.
56 'id' => 'image_scale_and_crop',
63 $this->effectUuid = $camelids->addImageEffect($effect);
73 protected function getExpectedNormalizedEntity() {
77 $this->effectUuid => [
78 'uuid' => $this->effectUuid,
79 'id' => 'image_scale_and_crop',
87 'label' => 'Camelids',
91 'uuid' => $this->entity->uuid(),
98 protected function getNormalizedPostEntity() {
99 // @todo Update in https://www.drupal.org/node/2300677.
105 protected function getExpectedUnauthorizedAccessMessage($method) {
106 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
107 return parent::getExpectedUnauthorizedAccessMessage($method);
110 return "The 'administer image styles' permission is required.";