@@ -10,59 +10,59 @@ 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 | - ]; |
|
33 | - |
|
34 | - /** |
|
35 | - * The test media bundle. |
|
36 | - * |
|
37 | - * @var \Drupal\media_entity\MediaBundleInterface |
|
38 | - */ |
|
39 | - protected $testBundle; |
|
40 | - |
|
41 | - /** |
|
42 | - * {@inheritdoc} |
|
43 | - */ |
|
44 | - protected function setUp() { |
|
32 | + ]; |
|
33 | + |
|
34 | + /** |
|
35 | + * The test media bundle. |
|
36 | + * |
|
37 | + * @var \Drupal\media_entity\MediaBundleInterface |
|
38 | + */ |
|
39 | + protected $testBundle; |
|
40 | + |
|
41 | + /** |
|
42 | + * {@inheritdoc} |
|
43 | + */ |
|
44 | + protected function setUp() { |
|
45 | 45 | parent::setUp(); |
46 | 46 | $this->testBundle = $this->container->get('entity_type.manager')->getStorage('media_bundle')->load('gallery'); |
47 | 47 | |
48 | 48 | $adminUser = $this->drupalCreateUser([ |
49 | - 'view media', |
|
50 | - 'create media', |
|
51 | - 'update media', |
|
52 | - 'update any media', |
|
53 | - 'delete media', |
|
54 | - 'delete any media', |
|
55 | - 'access media overview', |
|
49 | + 'view media', |
|
50 | + 'create media', |
|
51 | + 'update media', |
|
52 | + 'update any media', |
|
53 | + 'delete media', |
|
54 | + 'delete any media', |
|
55 | + 'access media overview', |
|
56 | 56 | ]); |
57 | 57 | $this->drupalLogin($adminUser); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Tests gallery media bundle creation from config files. |
|
62 | - */ |
|
63 | - public function testMediaBundleCreationFromModule() { |
|
60 | + /** |
|
61 | + * Tests gallery media bundle creation from config files. |
|
62 | + */ |
|
63 | + public function testMediaBundleCreationFromModule() { |
|
64 | 64 | $type_configuration = [ |
65 | - 'source_field' => 'field_slide', |
|
65 | + 'source_field' => 'field_slide', |
|
66 | 66 | ]; |
67 | 67 | |
68 | 68 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -71,21 +71,21 @@ discard block |
||
71 | 71 | $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.'); |
72 | 72 | $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
73 | 73 | $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.'); |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Tests thumbnail of the gallery item. |
|
78 | - */ |
|
79 | - public function testGalleryItemThumbnail() { |
|
76 | + /** |
|
77 | + * Tests thumbnail of the gallery item. |
|
78 | + */ |
|
79 | + public function testGalleryItemThumbnail() { |
|
80 | 80 | // Let's add one image and one video. |
81 | 81 | $imageItem = $this->addImageItem(); |
82 | 82 | $videoItem = $this->addVideoItem(); |
83 | 83 | $this->drupalGet('media/add/gallery'); |
84 | 84 | $pathValue = (string) current($this->xpath('//input[@data-drupal-selector="edit-field-slide-entity-browser-path"]/@value')); |
85 | 85 | $edit = [ |
86 | - 'name[0][value]' => 'Gallery item', |
|
87 | - 'field_slide[target_id]' => $imageItem['id'] . ' ' . $videoItem['id'], |
|
88 | - 'field_slide[entity_browser][path]' => $pathValue, |
|
86 | + 'name[0][value]' => 'Gallery item', |
|
87 | + 'field_slide[target_id]' => $imageItem['id'] . ' ' . $videoItem['id'], |
|
88 | + 'field_slide[entity_browser][path]' => $pathValue, |
|
89 | 89 | ]; |
90 | 90 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |
91 | 91 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | |
103 | 103 | $this->drupalGet('media/add/gallery'); |
104 | 104 | $edit = [ |
105 | - 'name[0][value]' => 'Gallery item 2', |
|
106 | - 'field_slide[target_id]' => $videoItem['id'] . ' ' . $imageItem['id'] , |
|
107 | - 'field_slide[entity_browser][path]' => $pathValue, |
|
105 | + 'name[0][value]' => 'Gallery item 2', |
|
106 | + 'field_slide[target_id]' => $videoItem['id'] . ' ' . $imageItem['id'] , |
|
107 | + 'field_slide[entity_browser][path]' => $pathValue, |
|
108 | 108 | ]; |
109 | 109 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |
110 | 110 | |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | $gallery = $this->loadMediaItem(reset($gallery_id)); |
114 | 114 | $gallery_thumbnail = $gallery->getType()->thumbnail($gallery); |
115 | 115 | $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected."); |
116 | - } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Adds image type item. |
|
120 | - */ |
|
121 | - public function addImageItem() { |
|
118 | + /** |
|
119 | + * Adds image type item. |
|
120 | + */ |
|
121 | + public function addImageItem() { |
|
122 | 122 | // Let's add image first. |
123 | 123 | $name = $this->randomMachineName(); |
124 | 124 | $testImage = current($this->drupalGetTestFiles('image')); |
125 | 125 | $file_path = $this->container->get('file_system')->realpath($testImage->uri); |
126 | 126 | $edit = [ |
127 | - 'name[0][value]' => $name, |
|
128 | - 'files[field_image_0]' => $file_path, |
|
127 | + 'name[0][value]' => $name, |
|
128 | + 'files[field_image_0]' => $file_path, |
|
129 | 129 | ]; |
130 | 130 | // Save the image. |
131 | 131 | $this->drupalPostForm('media/add/image', $edit, t('Save and publish')); |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $edit['id'] = $media_id; |
137 | 137 | |
138 | 138 | return $edit; |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Adds video type item. |
|
143 | - */ |
|
144 | - public function addVideoItem() { |
|
141 | + /** |
|
142 | + * Adds video type item. |
|
143 | + */ |
|
144 | + public function addVideoItem() { |
|
145 | 145 | $edit = [ |
146 | - 'name[0][value]' => 'Drupal video!', |
|
147 | - 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
146 | + 'name[0][value]' => 'Drupal video!', |
|
147 | + 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
148 | 148 | ]; |
149 | 149 | $this->drupalPostForm('media/add/video', $edit, t('Save and publish')); |
150 | 150 | // Obtain the video id. |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | $edit['id'] = $media_id; |
154 | 154 | |
155 | 155 | return $edit; |
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Loads the media entity item. |
|
160 | - * |
|
161 | - * @param int $id |
|
162 | - * The id of the item. |
|
163 | - * |
|
164 | - * @return \Drupal\media_entity\MediaInterface |
|
165 | - * The media entity item. |
|
166 | - */ |
|
167 | - public function loadMediaItem($id) { |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Loads the media entity item. |
|
160 | + * |
|
161 | + * @param int $id |
|
162 | + * The id of the item. |
|
163 | + * |
|
164 | + * @return \Drupal\media_entity\MediaInterface |
|
165 | + * The media entity item. |
|
166 | + */ |
|
167 | + public function loadMediaItem($id) { |
|
168 | 168 | $item = $this->container->get('entity_type.manager') |
169 | - ->getStorage('media') |
|
170 | - ->loadUnchanged($id); |
|
169 | + ->getStorage('media') |
|
170 | + ->loadUnchanged($id); |
|
171 | 171 | return $item; |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | 174 | } |
@@ -103,7 +103,7 @@ |
||
103 | 103 | $this->drupalGet('media/add/gallery'); |
104 | 104 | $edit = [ |
105 | 105 | 'name[0][value]' => 'Gallery item 2', |
106 | - 'field_slide[target_id]' => $videoItem['id'] . ' ' . $imageItem['id'] , |
|
106 | + 'field_slide[target_id]' => $videoItem['id'] . ' ' . $imageItem['id'], |
|
107 | 107 | 'field_slide[entity_browser][path]' => $pathValue, |
108 | 108 | ]; |
109 | 109 | $this->drupalPostForm(NULL, $edit, t('Save and publish')); |