@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | * @group media |
11 | 11 | */ |
12 | 12 | class GalleryBundleTest extends WebTestBase { |
13 | - /** |
|
14 | - * Exempt from strict schema checking. |
|
15 | - * |
|
16 | - * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker |
|
17 | - * |
|
18 | - * @var bool |
|
19 | - */ |
|
20 | - protected $strictConfigSchema = FALSE; |
|
21 | - |
|
22 | - /** |
|
23 | - * Modules to enable. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - public static $modules = [ |
|
13 | + /** |
|
14 | + * Exempt from strict schema checking. |
|
15 | + * |
|
16 | + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker |
|
17 | + * |
|
18 | + * @var bool |
|
19 | + */ |
|
20 | + protected $strictConfigSchema = FALSE; |
|
21 | + |
|
22 | + /** |
|
23 | + * Modules to enable. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + public static $modules = [ |
|
28 | 28 | 'media', |
29 | 29 | 'media_entity', |
30 | 30 | 'media_entity_slideshow', |
31 | 31 | 'node', |
32 | 32 | 'editor', |
33 | - ]; |
|
34 | - |
|
35 | - /** |
|
36 | - * The test media bundle. |
|
37 | - * |
|
38 | - * @var \Drupal\media_entity\MediaBundleInterface |
|
39 | - */ |
|
40 | - protected $testBundle; |
|
41 | - |
|
42 | - /** |
|
43 | - * {@inheritdoc} |
|
44 | - */ |
|
45 | - protected function setUp() { |
|
33 | + ]; |
|
34 | + |
|
35 | + /** |
|
36 | + * The test media bundle. |
|
37 | + * |
|
38 | + * @var \Drupal\media_entity\MediaBundleInterface |
|
39 | + */ |
|
40 | + protected $testBundle; |
|
41 | + |
|
42 | + /** |
|
43 | + * {@inheritdoc} |
|
44 | + */ |
|
45 | + protected function setUp() { |
|
46 | 46 | parent::setUp(); |
47 | 47 | $this->testBundle = $this->container->get('entity_type.manager')->getStorage('media_bundle')->load('gallery'); |
48 | 48 | |
49 | 49 | $adminUser = $this->drupalCreateUser([ |
50 | - 'view media', |
|
51 | - 'create media', |
|
52 | - 'update media', |
|
53 | - 'update any media', |
|
54 | - 'delete media', |
|
55 | - 'delete any media', |
|
56 | - 'access media overview', |
|
57 | - 'access gallery_media_library entity browser pages', |
|
50 | + 'view media', |
|
51 | + 'create media', |
|
52 | + 'update media', |
|
53 | + 'update any media', |
|
54 | + 'delete media', |
|
55 | + 'delete any media', |
|
56 | + 'access media overview', |
|
57 | + 'access gallery_media_library entity browser pages', |
|
58 | 58 | ]); |
59 | 59 | $this->drupalLogin($adminUser); |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Tests gallery media bundle creation from config files. |
|
64 | - */ |
|
65 | - public function testMediaBundleCreationFromModule() { |
|
62 | + /** |
|
63 | + * Tests gallery media bundle creation from config files. |
|
64 | + */ |
|
65 | + public function testMediaBundleCreationFromModule() { |
|
66 | 66 | $type_configuration = [ |
67 | - 'source_field' => 'field_slide', |
|
67 | + 'source_field' => 'field_slide', |
|
68 | 68 | ]; |
69 | 69 | |
70 | 70 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.'); |
74 | 74 | $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
75 | 75 | $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.'); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Tests thumbnail of the gallery item. |
|
80 | - */ |
|
81 | - public function testGalleryItemThumbnail() { |
|
78 | + /** |
|
79 | + * Tests thumbnail of the gallery item. |
|
80 | + */ |
|
81 | + public function testGalleryItemThumbnail() { |
|
82 | 82 | // Let's add one image and one video. |
83 | 83 | $imageItem = $this->addImageItem(); |
84 | 84 | $videoItem = $this->addVideoItem(); |
85 | 85 | $this->drupalGet('media/add/gallery'); |
86 | 86 | $pathValue = (string) current($this->xpath('//input[@data-drupal-selector="edit-field-slide-entity-browser-entity-browser-path"]/@value')); |
87 | 87 | $edit = [ |
88 | - 'name[0][value]' => 'Gallery item', |
|
89 | - 'field_slide[target_id]' => 'media:' . $imageItem['id'] . ' media:' . $videoItem['id'], |
|
90 | - 'field_slide[entity_browser][entity_browser][path]' => $pathValue, |
|
88 | + 'name[0][value]' => 'Gallery item', |
|
89 | + 'field_slide[target_id]' => 'media:' . $imageItem['id'] . ' media:' . $videoItem['id'], |
|
90 | + 'field_slide[entity_browser][entity_browser][path]' => $pathValue, |
|
91 | 91 | ]; |
92 | 92 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |
93 | 93 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | |
105 | 105 | $this->drupalGet('media/add/gallery'); |
106 | 106 | $edit = [ |
107 | - 'name[0][value]' => 'Gallery item 2', |
|
108 | - 'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] , |
|
109 | - 'field_slide[entity_browser][entity_browser][path]' => $pathValue, |
|
107 | + 'name[0][value]' => 'Gallery item 2', |
|
108 | + 'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] , |
|
109 | + 'field_slide[entity_browser][entity_browser][path]' => $pathValue, |
|
110 | 110 | ]; |
111 | 111 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |
112 | 112 | |
@@ -115,28 +115,28 @@ discard block |
||
115 | 115 | $gallery = $this->loadMediaItem(reset($gallery_id)); |
116 | 116 | $gallery_thumbnail = $gallery->getType()->thumbnail($gallery); |
117 | 117 | $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected."); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Tests that gallery option isn't available in gallery create bundle filters. |
|
122 | - */ |
|
123 | - public function testGalleryOption() { |
|
120 | + /** |
|
121 | + * Tests that gallery option isn't available in gallery create bundle filters. |
|
122 | + */ |
|
123 | + public function testGalleryOption() { |
|
124 | 124 | // Open the media library iframe used on add gallery page. |
125 | 125 | $this->drupalGet('entity-browser/modal/gallery_media_library'); |
126 | 126 | $this->assertNoOption('edit-bundle-1', 'gallery'); |
127 | - } |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Adds image type item. |
|
131 | - */ |
|
132 | - public function addImageItem() { |
|
129 | + /** |
|
130 | + * Adds image type item. |
|
131 | + */ |
|
132 | + public function addImageItem() { |
|
133 | 133 | // Let's add image first. |
134 | 134 | $name = $this->randomMachineName(); |
135 | 135 | $testImage = current($this->drupalGetTestFiles('image')); |
136 | 136 | $file_path = $this->container->get('file_system')->realpath($testImage->uri); |
137 | 137 | $edit = [ |
138 | - 'name[0][value]' => $name, |
|
139 | - 'files[field_image_0]' => $file_path, |
|
138 | + 'name[0][value]' => $name, |
|
139 | + 'files[field_image_0]' => $file_path, |
|
140 | 140 | ]; |
141 | 141 | // Save the image. |
142 | 142 | $this->drupalPostForm('media/add/image', $edit, t('Save and publish')); |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | $edit['id'] = $media_id; |
148 | 148 | |
149 | 149 | return $edit; |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * Adds video type item. |
|
154 | - */ |
|
155 | - public function addVideoItem() { |
|
152 | + /** |
|
153 | + * Adds video type item. |
|
154 | + */ |
|
155 | + public function addVideoItem() { |
|
156 | 156 | $edit = [ |
157 | - 'name[0][value]' => 'Drupal video!', |
|
158 | - 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
157 | + 'name[0][value]' => 'Drupal video!', |
|
158 | + 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
159 | 159 | ]; |
160 | 160 | $this->drupalPostForm('media/add/video', $edit, t('Save and publish')); |
161 | 161 | // Obtain the video id. |
@@ -164,22 +164,22 @@ discard block |
||
164 | 164 | $edit['id'] = $media_id; |
165 | 165 | |
166 | 166 | return $edit; |
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Loads the media entity item. |
|
171 | - * |
|
172 | - * @param int $id |
|
173 | - * The id of the item. |
|
174 | - * |
|
175 | - * @return \Drupal\media_entity\MediaInterface |
|
176 | - * The media entity item. |
|
177 | - */ |
|
178 | - public function loadMediaItem($id) { |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Loads the media entity item. |
|
171 | + * |
|
172 | + * @param int $id |
|
173 | + * The id of the item. |
|
174 | + * |
|
175 | + * @return \Drupal\media_entity\MediaInterface |
|
176 | + * The media entity item. |
|
177 | + */ |
|
178 | + public function loadMediaItem($id) { |
|
179 | 179 | $item = $this->container->get('entity_type.manager') |
180 | - ->getStorage('media') |
|
181 | - ->loadUnchanged($id); |
|
180 | + ->getStorage('media') |
|
181 | + ->loadUnchanged($id); |
|
182 | 182 | return $item; |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | 185 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | $this->drupalGet('media/add/gallery'); |
106 | 106 | $edit = [ |
107 | 107 | 'name[0][value]' => 'Gallery item 2', |
108 | - 'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] , |
|
108 | + 'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'], |
|
109 | 109 | 'field_slide[entity_browser][entity_browser][path]' => $pathValue, |
110 | 110 | ]; |
111 | 111 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |