Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/jsonapi/tests/src/Functional/ImageStyleTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\jsonapi\Functional; | |
4 | |
5 use Drupal\Core\Url; | |
6 use Drupal\image\Entity\ImageStyle; | |
7 | |
8 /** | |
9 * JSON:API integration test for the "ImageStyle" config entity type. | |
10 * | |
11 * @group jsonapi | |
12 */ | |
13 class ImageStyleTest extends ResourceTestBase { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 public static $modules = ['image']; | |
19 | |
20 /** | |
21 * {@inheritdoc} | |
22 */ | |
23 protected static $entityTypeId = 'image_style'; | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 protected static $resourceTypeName = 'image_style--image_style'; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 * | |
33 * @var \Drupal\image\ImageStyleInterface | |
34 */ | |
35 protected $entity; | |
36 | |
37 /** | |
38 * The effect UUID. | |
39 * | |
40 * @var string | |
41 */ | |
42 protected $effectUuid; | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function setUpAuthorization($method) { | |
48 $this->grantPermissionsToTestedRole(['administer image styles']); | |
49 } | |
50 | |
51 /** | |
52 * {@inheritdoc} | |
53 */ | |
54 protected function createEntity() { | |
55 // Create a "Camelids" image style. | |
56 $camelids = ImageStyle::create([ | |
57 'name' => 'camelids', | |
58 'label' => 'Camelids', | |
59 ]); | |
60 | |
61 // Add an image effect. | |
62 $effect = [ | |
63 'id' => 'image_scale_and_crop', | |
64 'data' => [ | |
65 'width' => 120, | |
66 'height' => 121, | |
67 ], | |
68 'weight' => 0, | |
69 ]; | |
70 $this->effectUuid = $camelids->addImageEffect($effect); | |
71 | |
72 $camelids->save(); | |
73 | |
74 return $camelids; | |
75 } | |
76 | |
77 /** | |
78 * {@inheritdoc} | |
79 */ | |
80 protected function getExpectedDocument() { | |
81 $self_url = Url::fromUri('base:/jsonapi/image_style/image_style/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); | |
82 return [ | |
83 'jsonapi' => [ | |
84 'meta' => [ | |
85 'links' => [ | |
86 'self' => ['href' => 'http://jsonapi.org/format/1.0/'], | |
87 ], | |
88 ], | |
89 'version' => '1.0', | |
90 ], | |
91 'links' => [ | |
92 'self' => ['href' => $self_url], | |
93 ], | |
94 'data' => [ | |
95 'id' => $this->entity->uuid(), | |
96 'type' => 'image_style--image_style', | |
97 'links' => [ | |
98 'self' => ['href' => $self_url], | |
99 ], | |
100 'attributes' => [ | |
101 'dependencies' => [], | |
102 'effects' => [ | |
103 $this->effectUuid => [ | |
104 'uuid' => $this->effectUuid, | |
105 'id' => 'image_scale_and_crop', | |
106 'weight' => 0, | |
107 'data' => [ | |
108 'anchor' => 'center-center', | |
109 'width' => 120, | |
110 'height' => 121, | |
111 ], | |
112 ], | |
113 ], | |
114 'label' => 'Camelids', | |
115 'langcode' => 'en', | |
116 'status' => TRUE, | |
117 'drupal_internal__name' => 'camelids', | |
118 ], | |
119 ], | |
120 ]; | |
121 } | |
122 | |
123 /** | |
124 * {@inheritdoc} | |
125 */ | |
126 protected function getPostDocument() { | |
127 // @todo Update in https://www.drupal.org/node/2300677. | |
128 } | |
129 | |
130 } |