@@ -11,50 +11,50 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class GalleryBundleTest extends WebTestBase { |
13 | 13 | |
14 | - /** |
|
15 | - * Modules to enable. |
|
16 | - * |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public static $modules = [ |
|
14 | + /** |
|
15 | + * Modules to enable. |
|
16 | + * |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public static $modules = [ |
|
20 | 20 | 'media', |
21 | 21 | 'media_entity', |
22 | 22 | 'media_entity_slideshow', |
23 | 23 | 'node', |
24 | - ]; |
|
25 | - |
|
26 | - /** |
|
27 | - * The test media bundle. |
|
28 | - * |
|
29 | - * @var \Drupal\media_entity\MediaBundleInterface |
|
30 | - */ |
|
31 | - protected $testBundle; |
|
32 | - |
|
33 | - /** |
|
34 | - * {@inheritdoc} |
|
35 | - */ |
|
36 | - protected function setUp() { |
|
24 | + ]; |
|
25 | + |
|
26 | + /** |
|
27 | + * The test media bundle. |
|
28 | + * |
|
29 | + * @var \Drupal\media_entity\MediaBundleInterface |
|
30 | + */ |
|
31 | + protected $testBundle; |
|
32 | + |
|
33 | + /** |
|
34 | + * {@inheritdoc} |
|
35 | + */ |
|
36 | + protected function setUp() { |
|
37 | 37 | parent::setUp(); |
38 | 38 | $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('gallery'); |
39 | 39 | |
40 | 40 | $adminUser = $this->drupalCreateUser([ |
41 | - 'view media', |
|
42 | - 'create media', |
|
43 | - 'update media', |
|
44 | - 'update any media', |
|
45 | - 'delete media', |
|
46 | - 'delete any media', |
|
47 | - 'access media overview', |
|
41 | + 'view media', |
|
42 | + 'create media', |
|
43 | + 'update media', |
|
44 | + 'update any media', |
|
45 | + 'delete media', |
|
46 | + 'delete any media', |
|
47 | + 'access media overview', |
|
48 | 48 | ]); |
49 | 49 | $this->drupalLogin($adminUser); |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Tests gallery media bundle creation from config files. |
|
54 | - */ |
|
55 | - public function testMediaBundleCreationFromModule() { |
|
52 | + /** |
|
53 | + * Tests gallery media bundle creation from config files. |
|
54 | + */ |
|
55 | + public function testMediaBundleCreationFromModule() { |
|
56 | 56 | $type_configuration = [ |
57 | - 'source_field' => 'field_slide', |
|
57 | + 'source_field' => 'field_slide', |
|
58 | 58 | ]; |
59 | 59 | |
60 | 60 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.'); |
64 | 64 | $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
65 | 65 | $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.'); |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Tests thumbnail of the gallery item. |
|
70 | - */ |
|
71 | - public function testGalleryItemThumbnail() { |
|
68 | + /** |
|
69 | + * Tests thumbnail of the gallery item. |
|
70 | + */ |
|
71 | + public function testGalleryItemThumbnail() { |
|
72 | 72 | // Let's add one image and one video. |
73 | 73 | $imageItem = $this->addImageItem(); |
74 | 74 | $videoItem = $this->addVideoItem(); |
75 | 75 | |
76 | 76 | $this->drupalGet('media/add/gallery'); |
77 | 77 | $edit = [ |
78 | - 'name[0][value]' => 'Gallery item', |
|
79 | - 'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')', |
|
80 | - 'field_slide[0][_weight]' => 0, |
|
78 | + 'name[0][value]' => 'Gallery item', |
|
79 | + 'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')', |
|
80 | + 'field_slide[0][_weight]' => 0, |
|
81 | 81 | ]; |
82 | 82 | $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more'); |
83 | 83 | $edit['field_slide[1][target_id]'] = $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')'; |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | |
98 | 98 | $this->drupalGet('media/add/gallery'); |
99 | 99 | $edit = [ |
100 | - 'name[0][value]' => 'Gallery item 2', |
|
101 | - 'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')', |
|
102 | - 'field_slide[0][_weight]' => 0, |
|
100 | + 'name[0][value]' => 'Gallery item 2', |
|
101 | + 'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')', |
|
102 | + 'field_slide[0][_weight]' => 0, |
|
103 | 103 | ]; |
104 | 104 | $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more'); |
105 | 105 | $edit['field_slide[1][target_id]'] = $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')'; |
@@ -111,19 +111,19 @@ discard block |
||
111 | 111 | $gallery = $this->loadMediaItem(reset($gallery_id)); |
112 | 112 | $gallery_thumbnail = $gallery->getType()->thumbnail($gallery); |
113 | 113 | $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected."); |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Adds image type item. |
|
118 | - */ |
|
119 | - public function addImageItem() { |
|
116 | + /** |
|
117 | + * Adds image type item. |
|
118 | + */ |
|
119 | + public function addImageItem() { |
|
120 | 120 | // Let's add image first. |
121 | 121 | $name = $this->randomMachineName(); |
122 | 122 | $testImage = current($this->drupalGetTestFiles('image')); |
123 | 123 | $file_path = $this->container->get('file_system')->realpath($testImage->uri); |
124 | 124 | $edit = [ |
125 | - 'name[0][value]' => $name, |
|
126 | - 'files[field_image_0]' => $file_path, |
|
125 | + 'name[0][value]' => $name, |
|
126 | + 'files[field_image_0]' => $file_path, |
|
127 | 127 | ]; |
128 | 128 | // Save the image. |
129 | 129 | $this->drupalPostForm('media/add/image', $edit, t('Save and publish')); |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | $edit['id'] = $media_id; |
135 | 135 | |
136 | 136 | return $edit; |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Adds video type item. |
|
141 | - */ |
|
142 | - public function addVideoItem() { |
|
139 | + /** |
|
140 | + * Adds video type item. |
|
141 | + */ |
|
142 | + public function addVideoItem() { |
|
143 | 143 | $edit = [ |
144 | - 'name[0][value]' => 'Drupal video!', |
|
145 | - 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
144 | + 'name[0][value]' => 'Drupal video!', |
|
145 | + 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
146 | 146 | ]; |
147 | 147 | $this->drupalPostForm('media/add/video', $edit, t('Save and publish')); |
148 | 148 | // Obtain the video id. |
@@ -151,22 +151,22 @@ discard block |
||
151 | 151 | $edit['id'] = $media_id; |
152 | 152 | |
153 | 153 | return $edit; |
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Loads the media entity item. |
|
158 | - * |
|
159 | - * @param int $id |
|
160 | - * The id of the item. |
|
161 | - * |
|
162 | - * @return \Drupal\media_entity\MediaInterface |
|
163 | - * The media entity item. |
|
164 | - */ |
|
165 | - public function loadMediaItem($id) { |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Loads the media entity item. |
|
158 | + * |
|
159 | + * @param int $id |
|
160 | + * The id of the item. |
|
161 | + * |
|
162 | + * @return \Drupal\media_entity\MediaInterface |
|
163 | + * The media entity item. |
|
164 | + */ |
|
165 | + public function loadMediaItem($id) { |
|
166 | 166 | $item = $this->container->get('entity_type.manager') |
167 | - ->getStorage('media') |
|
168 | - ->loadUnchanged($id); |
|
167 | + ->getStorage('media') |
|
168 | + ->loadUnchanged($id); |
|
169 | 169 | return $item; |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | 172 | } |