Mercurial > hg > isophonics-drupal-site
comparison core/modules/jsonapi/tests/src/Functional/ResponsiveImageStyleTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\jsonapi\Functional; | |
4 | |
5 use Drupal\Core\Url; | |
6 use Drupal\responsive_image\Entity\ResponsiveImageStyle; | |
7 | |
8 /** | |
9 * JSON:API integration test for the "ResponsiveImageStyle" config entity type. | |
10 * | |
11 * @group jsonapi | |
12 */ | |
13 class ResponsiveImageStyleTest extends ResourceTestBase { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 public static $modules = ['responsive_image']; | |
19 | |
20 /** | |
21 * {@inheritdoc} | |
22 */ | |
23 protected static $entityTypeId = 'responsive_image_style'; | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 protected static $resourceTypeName = 'responsive_image_style--responsive_image_style'; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 * | |
33 * @var \Drupal\responsive_image\ResponsiveImageStyleInterface | |
34 */ | |
35 protected $entity; | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 protected function setUpAuthorization($method) { | |
41 $this->grantPermissionsToTestedRole(['administer responsive images']); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function createEntity() { | |
48 // Create a "Camelids" responsive image style. | |
49 $camelids = ResponsiveImageStyle::create([ | |
50 'id' => 'camelids', | |
51 'label' => 'Camelids', | |
52 ]); | |
53 $camelids->setBreakpointGroup('test_group'); | |
54 $camelids->setFallbackImageStyle('fallback'); | |
55 $camelids->addImageStyleMapping('test_breakpoint', '1x', [ | |
56 'image_mapping_type' => 'image_style', | |
57 'image_mapping' => 'small', | |
58 ]); | |
59 $camelids->addImageStyleMapping('test_breakpoint', '2x', [ | |
60 'image_mapping_type' => 'sizes', | |
61 'image_mapping' => [ | |
62 'sizes' => '(min-width:700px) 700px, 100vw', | |
63 'sizes_image_styles' => [ | |
64 'medium' => 'medium', | |
65 'large' => 'large', | |
66 ], | |
67 ], | |
68 ]); | |
69 $camelids->save(); | |
70 | |
71 return $camelids; | |
72 } | |
73 | |
74 /** | |
75 * {@inheritdoc} | |
76 */ | |
77 protected function getExpectedDocument() { | |
78 $self_url = Url::fromUri('base:/jsonapi/responsive_image_style/responsive_image_style/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); | |
79 return [ | |
80 'jsonapi' => [ | |
81 'meta' => [ | |
82 'links' => [ | |
83 'self' => ['href' => 'http://jsonapi.org/format/1.0/'], | |
84 ], | |
85 ], | |
86 'version' => '1.0', | |
87 ], | |
88 'links' => [ | |
89 'self' => ['href' => $self_url], | |
90 ], | |
91 'data' => [ | |
92 'id' => $this->entity->uuid(), | |
93 'type' => 'responsive_image_style--responsive_image_style', | |
94 'links' => [ | |
95 'self' => ['href' => $self_url], | |
96 ], | |
97 'attributes' => [ | |
98 'breakpoint_group' => 'test_group', | |
99 'dependencies' => [ | |
100 'config' => [ | |
101 'image.style.large', | |
102 'image.style.medium', | |
103 ], | |
104 ], | |
105 'fallback_image_style' => 'fallback', | |
106 'image_style_mappings' => [ | |
107 0 => [ | |
108 'breakpoint_id' => 'test_breakpoint', | |
109 'image_mapping' => 'small', | |
110 'image_mapping_type' => 'image_style', | |
111 'multiplier' => '1x', | |
112 ], | |
113 1 => [ | |
114 'breakpoint_id' => 'test_breakpoint', | |
115 'image_mapping' => [ | |
116 'sizes' => '(min-width:700px) 700px, 100vw', | |
117 'sizes_image_styles' => [ | |
118 'large' => 'large', | |
119 'medium' => 'medium', | |
120 ], | |
121 ], | |
122 'image_mapping_type' => 'sizes', | |
123 'multiplier' => '2x', | |
124 ], | |
125 ], | |
126 'label' => 'Camelids', | |
127 'langcode' => 'en', | |
128 'status' => TRUE, | |
129 'drupal_internal__id' => 'camelids', | |
130 ], | |
131 ], | |
132 ]; | |
133 } | |
134 | |
135 /** | |
136 * {@inheritdoc} | |
137 */ | |
138 protected function getPostDocument() { | |
139 // @todo Update in https://www.drupal.org/node/2300677. | |
140 } | |
141 | |
142 } |