3 namespace Drupal\Tests\image\Functional\Rest;
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',
58 'anchor' => 'center-center',
64 $this->effectUuid = $camelids->addImageEffect($effect);
74 protected function getExpectedNormalizedEntity() {
78 $this->effectUuid => [
79 'uuid' => $this->effectUuid,
80 'id' => 'image_scale_and_crop',
83 'anchor' => 'center-center',
89 'label' => 'Camelids',
93 'uuid' => $this->entity->uuid(),
100 protected function getNormalizedPostEntity() {
101 // @todo Update in https://www.drupal.org/node/2300677.
107 protected function getExpectedUnauthorizedAccessMessage($method) {
108 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
109 return parent::getExpectedUnauthorizedAccessMessage($method);
112 return "The 'administer image styles' permission is required.";